Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
October 2009
- 3 participants
- 80 discussions
Author: tchemit
Date: 2009-10-05 21:16:52 +0200 (Mon, 05 Oct 2009)
New Revision: 1560
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx
Log:
simplify modules + refactor NavigationTree and Decorator api + add real JComboBox tag handler (incompatible with JAXX 1.X)
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.swing;
+
+import jaxx.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptor;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXComboBox;
+import jaxx.tags.DefaultComponentHandler;
+import jaxx.types.TypeManager;
+import org.w3c.dom.Element;
+
+import java.awt.event.ItemListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXComboBoxHandler extends DefaultComponentHandler {
+
+ public JAXXComboBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class);
+ addProxyEventInfo("getSelectedItem", ItemListener.class);
+ }
+
+ @Override
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,99 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+<JPanel layout='{new BorderLayout()}'>
+
+ <Object id='data' javaBean='helper.getSelectedBean(this)'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+String getType(Object data) {
+ if (data == null) {
+ return "no type";
+ }
+ if (data instanceof java.util.List<?>) {
+ java.util.List<?> l = (java.util.List<?>) data;
+ if (l.isEmpty()) {
+ return "Empty collection";
+ }
+ return "Collection of " + l.size() + " " + l.get(0).getClass().getSimpleName() + "(s)";
+ }
+ return data.getClass().getSimpleName();
+}
+
+String getContent(Object data) {
+ if (data == null) {
+ return "no content";
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (data instanceof java.util.List) {
+ for (Object o : ((java.util.List)data)) {
+ buffer.append(o).append("\n");
+ }
+ } else {
+ buffer.append(data);
+ }
+ return buffer.toString();
+}
+
+ImageIcon getImage(Object data) {
+ if (data == null) {
+ return null;
+ }
+ if (data instanceof Movie) {
+ return SwingUtil.createIcon(((Movie)data).getImage());
+ }
+ if (data instanceof People) {
+ return SwingUtil.createIcon(((People)data).getImage());
+ }
+ return null;
+}
+ ]]>
+ </script>
+
+ <JSplitPane id='splitPane'
+ orientation='{JSplitPane.VERTICAL_SPLIT}'
+ resizeWeight='0.5'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'>
+ <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}'
+ editable='false'
+ font-size='11'
+ text='{getContent(getData())}'/>
+ </JScrollPane>
+
+ <JScrollPane border='{new TitledBorder("Picture")}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
+ minimumSize='{SwingUtil.newMinDimension()}'>
+
+ <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/>
+
+ </JScrollPane>
+
+ </JSplitPane>
+</JPanel>
\ No newline at end of file
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,82 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'
+ useOnlyVisibleComponentDimension='true'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+helper.createModel(this);
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" };
+}
+
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ navigation.setSelectionInterval(0, 0);
+ splitPane.resetToPreferredSizes();
+ }
+ });
+ // expand the tree
+ SwingUtil.expandTree(navigation);
+ // auto-expand node when selected
+ SwingUtil.addExpandOnClickListener(navigation);
+}
+ ]]>
+ </script>
+
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_NEVER}'>
+
+ <JTree id="navigation"
+ font-size='11'
+ rootVisible='false'
+ showsRootHandles='false'
+ model='{helper.createTreeModel(this)}'
+ selectionModel="{helper.createTreeHandler(this)}"/>
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />-->
+
+ </JScrollPane>
+
+ <JPanel id="content" layout="{contentLayout}" />
+
+ </JSplitPane>
+
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,244 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.tree;
+
+import java.util.Arrays;
+
+import static jaxx.runtime.JAXXContextEntryDef.newListDef;
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.JAXXContext;
+
+
+import javax.swing.JPanel;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.decorator.DecoratorUtils;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.tree.NavigationTreeHandler;
+import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy;
+import jaxx.runtime.swing.tree.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.tree.NavigationTreeHelper;
+import jaxx.runtime.swing.tree.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.tree.NavigationTreeNode;
+import jaxx.runtime.swing.tree.NavigationTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class FullNavigationTreeHelper extends NavigationTreeHelper {
+
+ static {
+ // register decorator one for all
+
+ DecoratorUtils.register(
+ Movie.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - "));
+
+ DecoratorUtils.register(
+ People.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " "));
+ }
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+ /**
+ * where the movies are hold in context
+ */
+ static public final JAXXContextEntryDef<List<Movie>> MOVIES = JAXXContextEntryDef.newListDef("movies");
+ /**
+ * where the actors are hold in context
+ */
+ static public final JAXXContextEntryDef<List<People>> ACTORS = JAXXContextEntryDef.newListDef("actors");
+
+ public FullNavigationTreeHelper() {
+ super("full");
+ }
+
+ /**
+ * Create the model and store it in the given context.
+ *
+ * @param context the context where to hold the model
+ */
+ public void createModel(JAXXContext context) {
+ People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
+ People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
+ People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
+
+ Movie m = new Movie("0", "Nacho libre", 1996, "/jaxx/demo/images/nacho.jpg");
+ m.addActor(a);
+ m.addActor(a2);
+ m.addActor(a3);
+
+ Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m2.addActor(a);
+ m2.addActor(a2);
+
+ MOVIES.setContextValue(context, Arrays.asList(m, m2));
+ ACTORS.setContextValue(context, Arrays.asList(a, a2, a3));
+ }
+
+ @Override
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
+
+ List<Movie> movies = MOVIES.getContextValue(context);
+ List<People> actors = ACTORS.getContextValue(context);
+
+ if (log.isDebugEnabled()) {
+ log.debug("for " + movies.size() + " movie(s)");
+ }
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/", context, BaseContent.class,
+ null);
+
+ Decorator<Movie> mDecorator = DecoratorUtils.get(Movie.class.getSimpleName());
+ Decorator<People> pDecorator = DecoratorUtils.get(People.class.getSimpleName());
+
+ // construction du noeud root
+ // il ne contient pas de context et ne sera pas visible
+ NavigationTreeNode rootNode = builder.buildEmptyRoot(null, "$root");
+
+ // construction du noeud avec les films recupere la liste des films
+ // dans le context avec la clef movies
+ // navigation path = $root/movies
+ NavigationTreeNode moviesNode = builder.build(
+ rootNode,
+ _("movies"),
+ newListDef("movies"),
+ "movies",
+ null,
+ null);
+
+ for (Movie m : movies) {
+
+ // navigation path = $root/movies/m.id
+ NavigationTreeNode movieNode = builder.build(
+ moviesNode,
+ mDecorator,
+ "..[@id=\"" + m.getId() + "\"]",
+ m.getId(),
+ null,
+ null);
+
+ // navigation path = $root/movies/m.id/actors
+ NavigationTreeNode actorsNode = builder.build(
+ movieNode,
+ _("actors"),
+ "../actors",
+ "actors",
+ null,
+ null);
+
+ for (People p : m.getActors()) {
+ // navigation path = $root/movies/m.id/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ }
+
+ // construction du noeud avec les acteurs
+ NavigationTreeNode actorsNode = builder.build(rootNode, _("actors"),
+ newListDef("actors"),
+ "actors", null, null);
+
+ for (People p : actors) {
+ // navigation path = $root/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ NavigationTreeModel model = builder.getModel();
+
+ if (log.isDebugEnabled()) {
+ builder.printModel(model.getRoot());
+ }
+
+ // save tree model in context
+ setTreeModel(context, model);
+ return model;
+ }
+
+ @Override
+ public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("create handler");
+ }
+
+ NavigationTreeHandler handler;
+
+ handler = new NavigationTreeHandlerWithCardLayout(
+ getPrefix(),
+ context,
+ Strategy.PER_NODE) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected NavigationTreeModel getNavigationTreeModel() {
+ return getSafeTreeModel(getContext());
+ }
+
+ @Override
+ protected JPanel getContentContainer() {
+ return getContext().getContent();
+ }
+
+ @Override
+ protected CardLayout2 getContentLayout() {
+ return getContext().getContentLayout();
+ }
+
+ @Override
+ protected void treateError(Exception e) {
+ ErrorDialogUI.showError(e);
+ }
+
+ @Override
+ public FullNavigationTreeDemo getContext() {
+ return (FullNavigationTreeDemo) this.context;
+ }
+ };
+ // on ne peut selectionner qu'un seul noeud a la fois
+ handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+
+ // save handler in ui context
+ setTreeHandler(context, handler);
+ return handler;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,128 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,118 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.tree;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,34 @@
+package jaxx.runtime.decorator;
+
+/**
+ * A simple contract to define a String decorator on any java objet.
+ *
+ * @param <O> the type of data to decorate
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.Decorator})
+ */
+public abstract class Decorator<O> implements java.io.Serializable {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Type of the data to decorate
+ */
+ protected final Class<O> internalClass;
+
+ public Decorator(Class<O> internalClass) throws NullPointerException {
+ if (internalClass == null) {
+ throw new NullPointerException("internalClass can not be null.");
+ }
+ this.internalClass = internalClass;
+ }
+
+ /**
+ * @param bean the bean to decorate
+ * @return the string value of the given bean
+ */
+ public abstract String toString(Object bean);
+
+ public Class<O> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/Decorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,294 @@
+package jaxx.runtime.decorator;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.StringTokenizer;
+import jaxx.runtime.decorator.JXPathDecorator.JXPathComparator;
+import jaxx.runtime.decorator.JXPathDecorator.Context;
+
+/**
+ *
+ * Some usefull methods on {@link Decorator} to create, decorators and obtain decorators.
+ *
+ * To create a new decorator, use one of the methods :
+ * <ul>
+ * <li>{@link #newPropertyDecorator(Class, String)}</li>
+ * <li>{@link #newJXPathDecorator(Class, String)}</li>
+ * <li>{@link #newMultiJXPathDecorator(Class, String, String)})</li>
+ * <li>{@link #newMultiJXPathDecorator(Class, String, String, String)})</li>
+ * </ul>
+ * <p/>
+ *
+ * To register a new decorator, use the method {@link #register(String, Decorator)}.
+ * <p/>
+ * To obtain a registred decorator, use the method {@link #get(String)}
+ * (get the decorator based on his registred name). or the method {@link #get(Class, tring)}
+ * (get the decorator based on the type of decorator and the registred name).
+ * <p/>
+ * To sort a list of data, using a {@link JXPathDecorator}, use the method
+ * {@link #sort(JXPathDecorator, java.util.List, int)}.
+ * <p/>
+ *
+ * @author tony
+ * @since 1.7.2 (was previously {@code jaxx.runtime.DecoratorUtils})
+ */
+public class DecoratorUtils {
+
+ /**
+ * Registred decorators.
+ */
+ protected static List<DecoratorContext<?>> decorators;
+
+ /**
+ * Factory method to instanciate a new {@link PropertyDecorator} for the
+ * given class {@link O} and a readable property name.
+ *
+ * @param internalClass the class of the objects decorated by the new decorator
+ * @param property the property
+ * @param <O> the generic type of class to be decorated by the new decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if internalClass parameter is null.
+ */
+ public static <O> PropertyDecorator<O> newPropertyDecorator(Class<O> internalClass, String property)
+ throws IllegalArgumentException, NullPointerException {
+ return new PropertyDecorator<O>(internalClass, property);
+ }
+
+ /**
+ * Factory method to instanciate a new {@link JXPathDecorator} for the
+ * given class {@link O} and expression.
+ *
+ * @param internalClass the class of the objects decorated by the new decorator
+ * @param expression the expression to use to decorated objects
+ * @param <O> the generic type of class to be decorated by the new decorator
+ * @return the new instanciated decorator
+ * @throws IllegalArgumentException if the expression is not valid, says:
+ * <p/>
+ * - a missing right brace was detected.
+ * <p/>
+ * - a ${ was found in a jxpath token.
+ * @throws NullPointerException if internalClass parameter is null.
+ */
+ public static <O> JXPathDecorator<O> newJXPathDecorator(Class<O> internalClass, String expression)
+ throws IllegalArgumentException, NullPointerException {
+
+ Context<O> context = createJXPathContext(expression);
+ return new JXPathDecorator<O>(internalClass, expression, context);
+ }
+
+ public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass,
+ String expression,
+ String separator)
+ throws IllegalArgumentException, NullPointerException {
+
+ return newMultiJXPathDecorator(internalClass, expression, separator, separator);
+ }
+
+ public static <O> MultiJXPathDecorator<O> newMultiJXPathDecorator(Class<O> internalClass,
+ String expression,
+ String separator,
+ String separatorReplacement)
+ throws IllegalArgumentException, NullPointerException {
+
+ Context<O>[] contexts = createMultiJXPathContext(expression, separator, separatorReplacement);
+
+ return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts);
+ }
+
+ public static <T> Decorator<T> get(String context) {
+ Decorator<T> result = get(null, context);
+ return result;
+ }
+
+ public static <T> Decorator<T> get(Class<T> type, String context) {
+ DecoratorContext<T> decoratorContext = getDecoratorContext(type, context);
+ Decorator<T> result = decoratorContext == null ? null : decoratorContext.getDecorator();
+ return result;
+ }
+
+ /**
+ * Register a new decorator in the cache.
+ *
+ * @param <T> type of data decorated
+ * @param context the name decorator
+ * @param decorator the decorator to register
+ */
+ public static <T> void register(String context, Decorator<T> decorator) {
+
+ DecoratorContext<T> result = getDecoratorContext(decorator.getInternalClass(), context);
+
+ if (result != null) {
+ throw new IllegalArgumentException("there is an already register decorator " + result);
+ }
+
+ if (decorators == null) {
+ decorators = new java.util.ArrayList<DecoratorContext<?>>();
+ }
+ decorators.add(new DecoratorContext<T>(context, decorator));
+ }
+
+ public static void clear() {
+ if (decorators != null) {
+ decorators.clear();
+ }
+ }
+
+ /**
+ * 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 = 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();
+ }
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected static <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) {
+ DecoratorContext<T> result = null;
+ if (decorators != null) {
+ for (DecoratorContext<?> d : decorators) {
+ if (type == null) {
+ if (d.accept(context)) {
+ result = (DecoratorContext<T>) d;
+ break;
+ }
+ continue;
+ }
+ if (d.accept(type, context)) {
+ result = (DecoratorContext<T>) d;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static class DecoratorContext<T> {
+
+ final String context;
+ final Decorator<T> decorator;
+
+ public DecoratorContext(String context, Decorator<T> decorator) {
+ this.context = context;
+ this.decorator = decorator;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public Decorator<T> getDecorator() {
+ return decorator;
+ }
+
+ public Class<T> getType() {
+ return decorator.getInternalClass();
+ }
+
+ public boolean accept(Class<?> type, String context) {
+ return getType().isAssignableFrom(type) && accept(context);
+ }
+
+ public boolean accept(String context) {
+ return ((this.context == null && context == null) || (this.context != null && this.context.equals(context)));
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<type: " + getType().getName() + ", context :" + context + ">";
+ }
+ }
+
+ public static <O> Context<O> createJXPathContext(String expression) {
+ List<String> lTokens = new ArrayList<String>();
+ StringBuilder buffer = new StringBuilder();
+ int size = expression.length();
+ int end = -1;
+ int start;
+ while ((start = expression.indexOf("${", end + 1)) > -1) {
+ if (start > end + 1) {
+ // prefix of next jxpath token
+ buffer.append(expression.substring(end + 1, start));
+ }
+ // seek end of jxpath
+ end = expression.indexOf("}", start + 1);
+ if (end == -1) {
+ throw new IllegalArgumentException("could not find the rigth brace starting at car " + start + " : " + expression.substring(start + 2));
+ }
+ String jxpath = expression.substring(start + 2, end);
+ // not allowed ${ inside a jxpath token
+ if (jxpath.indexOf("${") > -1) {
+ throw new IllegalArgumentException("could not find a ${ inside a jxpath expression at car " + (start + 2) + " : " + jxpath);
+ }
+ // save the jxpath token
+ lTokens.add(jxpath);
+ // replace jxpath token in expresion with a string format variable
+ buffer.append("%").append(lTokens.size());
+ }
+ if (size > (end + 1)) {
+ // suffix after end jxpath (or all expression if no jxpath)
+ buffer.append(expression.substring(end + 1));
+ }
+ return new Context<O>(buffer.toString(), lTokens.toArray(new String[lTokens.size()]));
+ }
+
+ public static <O> Context<O>[] createMultiJXPathContext(String expression, String separator, String separatorReplacement) {
+ int sep = expression.indexOf(separator);
+ if (sep == -1) {
+ Context<O>[] result = newInstance(1);
+ result[0] = createJXPathContext(expression);
+ return result;
+ }
+
+ List<String> tokens = new ArrayList<String>();
+ StringTokenizer stk = new StringTokenizer(expression, separator);
+ while (stk.hasMoreTokens()) {
+ tokens.add(stk.nextToken());
+ }
+
+ int nbTokens = tokens.size();
+ Context<O>[] contexts = newInstance(nbTokens);
+ for (int i = 0; i < nbTokens; i++) {
+ StringBuilder buffer = new StringBuilder(expression.length());
+ for (int j = 0; j < nbTokens; j++) {
+ int index = (i + j) % nbTokens;
+ String str = tokens.get(index);
+ //todo replace %index with %j
+ buffer.append(separatorReplacement).append(str);
+ }
+ contexts[i] = createJXPathContext(buffer.substring(separatorReplacement.length()));
+ }
+ return contexts;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected static <O> Context<O>[] newInstance(int size) {
+ // fixme how to instanciate a typed array with no checking warning ?
+ return new Context[size];
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,197 @@
+package jaxx.runtime.decorator;
+
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JXPath decorator based on {@link String#format(String, Object[])} method.
+ * <p/>
+ * To use it, give to him a expression where all jxpath to apply on bean are boxed in <code>${}</code>.
+ * <p/>
+ * After the jxpath token you must specifiy the formatter to apply of the jxpath token.
+ * <p/>
+ * For example :
+ * <pre>
+ * Decorator<Object> d = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class,"expr = ${expressions}$s");
+ * assert "expr = %1$s" == d.getExpression();
+ * assert 1 == d.getNbToken();
+ * assert java.util.Arrays.asList("expression") == d.getTokens();
+ * assert "expr = %1$s" == d.toString(d);
+ * </pre>
+ *
+ * @param <O> type of data to decorate
+ * @author chemit
+ * @see Decorator
+ * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecorat})
+ */
+public class JXPathDecorator<O> extends Decorator<O> {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(JXPathDecorator.class);
+ /** the computed context of the decorator */
+ protected Context<O> context;
+ /** nb jxpath tokens to compute */
+ protected int nbToken;
+ /** the initial expression used to compute the decorator context. */
+ protected String initialExpression;
+
+ protected JXPathDecorator(Class<O> internalClass, String expression, Context<O> context) throws IllegalArgumentException, NullPointerException {
+ super(internalClass);
+ this.initialExpression = expression;
+ if (context != null) {
+ setContext(context);
+ }
+ }
+
+ @Override
+ public String toString(Object bean) {
+ if (bean == null) {
+ return null;
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(bean);
+ Object[] args = new Object[nbToken];
+
+ for (int i = 0; i < nbToken; i++) {
+ try {
+ args[i] = getTokenValue(jxcontext, context.tokens[i]);
+ } catch (Exception e) {
+ log.error("can not obtain token " + context.tokens[i] + "on object " + bean + " for reason " + e.getMessage(), e);
+
+ }
+ }
+
+ return String.format(context.expression, args);
+ }
+
+ public String getProperty(int pos) {
+ return getTokens()[pos];
+ }
+
+ public String getExpression() {
+ return context.expression;
+ }
+
+ public String[] getTokens() {
+ return context.tokens;
+ }
+
+ public int getNbToken() {
+ return nbToken;
+ }
+
+ public String getInitialExpression() {
+ return initialExpression;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<" + context + ">";
+ }
+
+ public void setContext(Context<O> context) {
+ this.context = context;
+ this.nbToken = context.tokens.length;
+ // always reset comparator
+ //this.context.comparator = null;
+ if (log.isDebugEnabled()) {
+ log.debug(context);
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected Comparator<O> getComparator(int pos) {
+ ensureTokenIndex(this, pos);
+ return context.getComparator(pos);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
+ // assume all values are comparable
+ return (Comparable<Comparable<?>>) jxcontext.getValue(token);
+ }
+
+ public static class JXPathComparator<O> implements Comparator<O> {
+
+ protected Map<O, Comparable<Comparable<?>>> valueCache;
+ private final String expression;
+
+ public JXPathComparator(String expression) {
+ this.expression = expression;
+ 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);
+ return c1.compareTo(c2);
+ }
+
+ public void clear() {
+ valueCache.clear();
+ }
+
+ public void init(JXPathDecorator<O> decorator, List<O> datas) {
+ clear();
+ for (O data : datas) {
+ JXPathContext jxcontext = JXPathContext.newContext(data);
+ Comparable<Comparable<?>> key = decorator.getTokenValue(jxcontext, expression);
+ valueCache.put(data, key);
+ }
+ }
+ }
+
+ public static class Context<O> implements java.io.Serializable {
+
+ /**
+ * expression to format using {@link String#format(String, Object[])}, all variables are compute
+ * using using the jxpath tokens.
+ */
+ protected String expression;
+ /** list of jxpath tokens to apply on expression */
+ protected String[] tokens;
+ protected transient Comparator<O> comparator;
+ private static final long serialVersionUID = 1L;
+
+ public Context(String expression, String[] tokens) {
+ this.expression = expression;
+ this.tokens = tokens;
+ }
+
+ public String getFirstProperty() {
+ return tokens[0];
+ }
+
+ public Comparator<O> getComparator(int pos) {
+ if (comparator == null) {
+ comparator = new JXPathComparator<O>(tokens[pos]);
+ }
+ return comparator;
+ }
+
+ public void setComparator(Comparator<O> comparator) {
+ this.comparator = comparator;
+ }
+
+ @Override
+ public String toString() {
+ return "<expression:" + expression + ", tokens:" + Arrays.toString(tokens) + ">";
+ }
+ }
+
+ 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 + "]");
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/JXPathDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,80 @@
+package jaxx.runtime.decorator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Comparator;
+
+/**
+ * TODO
+ *
+ * @param <O> type of data to decorate
+ * @author chemit
+ * @see Decorator
+ * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecorator})
+ */
+public class MultiJXPathDecorator<O> extends JXPathDecorator<O> {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class);
+ /**
+ * Contexts of the decorator
+ */
+ protected Context<O>[] contexts;
+ /**
+ * context separator
+ */
+ protected String separator;
+ /**
+ * context separator replacement
+ */
+ protected String separatorReplacement;
+
+ protected MultiJXPathDecorator(Class<O> internalClass, String expression,
+ String separator, String separatorReplacement,
+ Context<O>[] contexts) throws IllegalArgumentException, NullPointerException {
+ super(internalClass, expression, null);
+ this.separator = separator;
+ this.separatorReplacement = separatorReplacement;
+ this.contexts = contexts;
+
+ setContextIndex(0);
+
+ if (log.isDebugEnabled()) {
+ log.debug(expression + " --> " + this.context);
+ }
+ }
+
+ public void setContextIndex(int index) {
+ ensureContextIndex(this, index);
+ setContext(contexts[index]);
+ }
+
+ public int getNbContext() {
+ return contexts.length;
+ }
+
+ public String getSeparator() {
+ return separator;
+ }
+
+ public String getSeparatorReplacement() {
+ return separatorReplacement;
+ }
+
+ @Override
+ protected Comparator<O> getComparator(int pos) {
+ ensureContextIndex(this, pos);
+ Context<O> context1 = contexts[pos];
+ return context1.getComparator(0);
+ }
+
+ protected void ensureContextIndex(MultiJXPathDecorator<?> decorator, int pos) {
+ if (pos < -1 || pos > decorator.contexts.length) {
+ throw new ArrayIndexOutOfBoundsException("context index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.contexts.length + "]");
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/MultiJXPathDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,76 @@
+package jaxx.runtime.decorator;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+
+/**
+ * Simple property decorator based on {@link String#format(String, Object[])} method.
+ * <p/>
+ * To use it, give him a class and the property name to render.
+ * <p/>
+ * For example :
+ * <pre>
+ * Decorator<Object> d = DecoratorUtils.newPropertyDecorator(PropertyDecorator.class,"expressions");
+ * </pre>
+ *
+ * @param <O> type of data to decorate
+ * @author chemit
+ * @see Decorator
+ * @since 1.7.2 (was previously {@code jaxx.runtime.PropertyDecorator})
+ */
+public class PropertyDecorator<O> extends Decorator<O> {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(PropertyDecorator.class);
+ /**
+ * name of property
+ */
+ protected String property;
+ protected transient Method m;
+
+ @Override
+ public String toString(Object bean) {
+ try {
+ return getM().invoke(bean) + "";
+ } catch (Exception e) {
+ log.error("could not convert for reason : " + e, e);
+ return "";
+ }
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ protected PropertyDecorator(Class<O> internalClass, String property) throws NullPointerException {
+ super(internalClass);
+ if (property == null) {
+ throw new NullPointerException("property can not be null.");
+ }
+ this.property = property;
+ // init method
+ getM();
+ }
+
+ protected Method getM() {
+ if (m == null) {
+ for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(internalClass)) {
+ if (propertyDescriptor.getName().equals(property)) {
+ this.m = propertyDescriptor.getReadMethod();
+ break;
+ }
+ }
+ if (m == null) {
+ throw new IllegalArgumentException("could not find the property " + property + " in " + internalClass);
+ }
+ }
+ return m;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/PropertyDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,47 @@
+package jaxx.runtime.decorator.swing;
+
+import jaxx.runtime.decorator.*;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+
+/**
+ * A {@link ListCellRenderer} which compute text with the given {@link #decorator}
+ * and leave the hand to the {@link #delegate} to perform the visual renderer.
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class DecoratorListCellRenderer implements ListCellRenderer {
+
+ /**
+ * Delegate cell renderer
+ */
+ protected ListCellRenderer delegate;
+ /**
+ * Decorator to produce text to render
+ */
+ protected Decorator<?> decorator;
+
+ public DecoratorListCellRenderer(Decorator<?> decorator) {
+ this(new DefaultListCellRenderer(), decorator);
+ }
+
+ public DecoratorListCellRenderer(ListCellRenderer delegate, Decorator<?> decorator) {
+ this.delegate = delegate;
+ this.decorator = decorator;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ if (value != null) {
+ if (value instanceof String) {
+ value = (String) value;
+ } else {
+ value = decorator.toString(value);
+ }
+ }
+ return delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorListCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,43 @@
+package jaxx.runtime.decorator.swing;
+
+import jaxx.runtime.decorator.*;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * A {@link TableCellRenderer} which compute text with the given {@link #decorator}
+ * and leave the hand to the {@link #delegate} to perform the visual renderer.
+ *
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.swing.DecoratorTableCellRenderer}).
+ */
+public class DecoratorTableCellRenderer implements TableCellRenderer {
+
+ /**
+ * Delegate cell renderer
+ */
+ protected TableCellRenderer delegate;
+ /**
+ * Decorator to produce text to render
+ */
+ protected Decorator<?> decorator;
+
+ public DecoratorTableCellRenderer(Decorator<?> decorator) {
+ this(new DefaultTableCellRenderer(), decorator);
+ }
+
+ public DecoratorTableCellRenderer(TableCellRenderer delegate, Decorator<?> decorator) {
+ this.delegate = delegate;
+ this.decorator = decorator;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ if (value != null) {
+ value = decorator.toString(value);
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/swing/DecoratorTableCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,150 @@
+package jaxx.runtime.swing.tree;
+
+import javax.swing.JTree;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+
+/**
+ * To help getting and setting navigation tree objects from a {@link JAXXContext}.
+ * <p/>
+ * There is six types of data which can be hold in a context :
+ * <ul>
+ * <li>tree : the tree </li>
+ * <li>tree model : the navigation tree model</li>
+ * <li>tree handler : the navigation tree handler</li>
+ * <li>selected path : the navigation path of the selected node</li>
+ * <li>selected node : the selected node</li>
+ * <li>selected bean : the selected bean</li>
+ * </ul>
+ *
+ * To make possible the use of more than one navigation tree system in a same
+ * context, we <b>MUST</b> distinguish the context entries definition. For this
+ * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}.
+ * <p/>
+ * Here is the keys mapping :
+ * <ul>
+ * <li>tree : {@code prefix + "-tree"}</li>
+ * <li>tree model : {@code prefix + "-tree-model"}</li>
+ * <li>tree handler : {@code prefix + "-tree-handler"}</li>
+ * <li>selected path : {@code prefix + "-selected-path"}</li>
+ * <li>selected node : {@code prefix + "-selected-node"}</li>
+ * <li>selected bean : {@code prefix + "-selected-bean"}</li>
+ * </ul>
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeContextHelper {
+
+ protected final String prefix;
+ protected JAXXContextEntryDef<String> selectedPathContextEntry;
+ protected JAXXContextEntryDef<Object> selectedBeanContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry;
+ protected JAXXContextEntryDef<JTree> treeContextEntry;
+
+ public NavigationTreeContextHelper(String prefix) {
+ this.prefix = prefix;
+ treeContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree", JTree.class);
+ treeModelContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-model", NavigationTreeModel.class);
+ treeHandlerContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-handler", NavigationTreeHandler.class);
+ selectedBeanContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-bean", Object.class);
+ selectedNodeContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-node", NavigationTreeNode.class);
+ selectedPathContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-path", String.class);
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public JTree getTree(JAXXContext context) {
+ JTree r = getTreeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeModel getTreeModel(JAXXContext context) {
+ NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeHandler getTreeHandler(JAXXContext context) {
+ NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public String getSelectedPath(JAXXContext context) {
+ String r = getSelectedPathContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeNode getSelectedNode(JAXXContext context) {
+ NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public Object getSelectedBean(JAXXContext context) {
+ Object r = getSelectedBeanContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public void setTreeModel(JAXXContext context, NavigationTreeModel model) {
+ getTreeModelContextEntry().setContextValue(context, model);
+ }
+
+ public void setTree(JAXXContext context, JTree tree) {
+ getTreeContextEntry().setContextValue(context, tree);
+ }
+
+ public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) {
+ getTreeHandlerContextEntry().setContextValue(context, handler);
+ }
+
+ public void setSelectedPath(JAXXContext context, String path) {
+ if (path == null) {
+ getSelectedPathContextEntry().removeContextValue(context);
+ } else {
+ getSelectedPathContextEntry().setContextValue(context, path);
+ }
+ }
+
+ public void setSelectedNode(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ getSelectedNodeContextEntry().removeContextValue(context);
+ } else {
+ getSelectedNodeContextEntry().setContextValue(context, node);
+ }
+ }
+
+ public void setSelectedBean(JAXXContext context, Object bean) {
+ if (bean == null) {
+ getSelectedBeanContextEntry().removeContextValue(context);
+ } else {
+ getSelectedBeanContextEntry().setContextValue(context, bean);
+ }
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() {
+ return treeModelContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() {
+ return treeHandlerContextEntry;
+ }
+
+ protected JAXXContextEntryDef<Object> getSelectedBeanContextEntry() {
+ return selectedBeanContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() {
+ return selectedNodeContextEntry;
+ }
+
+ protected JAXXContextEntryDef<String> getSelectedPathContextEntry() {
+ return selectedPathContextEntry;
+ }
+
+ protected JAXXContextEntryDef<JTree> getTreeContextEntry() {
+ return treeContextEntry;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,275 @@
+package jaxx.runtime.swing.tree;
+
+import java.awt.Component;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The handler of a navigation tree.
+ *
+ * This is also the selection model to use, since we must check before moving
+ * from a node we can not just listen selection model changed, we must control
+ * it.
+ *
+ * @author tony
+ * @since 1.7.2
+ */
+public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandler.class);
+
+ /**
+ * Strategy of instanciation of ui.
+ * <p/>
+ * For a given {@code node}, the method {@link #getId(NavigationTreeNode)}
+ * returns the id of ui to use.
+ */
+ public enum Strategy {
+
+ /**
+ * instanciate a ui for a node
+ */
+ PER_NODE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getFullPath();
+ }
+ },
+ /**
+ * instanciate only one a ui for a type,nodes will share the instanciation
+ */
+ PER_UI_TYPE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getUIClass().getName();
+ }
+ };
+
+ public abstract String getId(NavigationTreeNode node);
+ }
+ /**
+ * UI which contains navigation tree
+ */
+ protected JAXXContext context;
+ /**
+ * UI Instanciation strategy
+ */
+ protected Strategy strategy;
+ /**
+ * JAXXContext access helper.
+ *
+ * @since 1.7.2
+ */
+ protected NavigationTreeContextHelper contextHelper;
+
+ protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
+ this.contextHelper = new NavigationTreeContextHelper(contextPrefix);
+ this.context = context;
+ this.strategy = strategy;
+ addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
+ // do not treate this if no path changed
+ return;
+ }
+ NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+ selectNodeUI(node);
+ }
+ });
+ }
+
+ /**
+ * @return le modèle de navigation associé
+ */
+ protected abstract NavigationTreeModel getNavigationTreeModel();
+
+ /**
+ * @return le composent actuellement visible associé au noeud courant ou
+ * au noeud précédent lors d'un changement de noeud.
+ */
+ protected abstract Component getCurrentUI();
+
+ /**
+ * @param node le noeud associé à l'ui à retrouver
+ * @return l'ui associé au novueau noeud sélectionné
+ */
+ protected abstract Component getUI(NavigationTreeNode node);
+
+ /**
+ * @param component le composent actuellement visible
+ * @return <code>true</code> si le composent a bien été fermé, <code>false</code> sinon
+ * @throws Exception if any
+ */
+ protected abstract boolean closeUI(Component component) throws Exception;
+
+ /**
+ * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return la nouvelle ui associée au noeud
+ * @throws Exception if any
+ */
+ protected abstract Component createUI(NavigationTreeNode node) throws Exception;
+
+ /**
+ * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
+ *
+ * @param newUI l'ui associé au noeud sélectionné à ouvrir
+ * @param node le node de l'ui a ouvrir
+ * @throws Exception if any
+ */
+ protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception;
+
+ /**
+ * Traitement des exceptions.
+ *
+ * @param e l'erreur recontrée (ou null si pas d"erreur)
+ */
+ protected abstract void treateError(Exception e);
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ public NavigationTreeContextHelper getContextHelper() {
+ return contextHelper;
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ if (path.equals(getSelectionPath())) {
+ // stay on same node, can skip
+ if (log.isDebugEnabled()) {
+ log.debug("skip stay on path " + path);
+ }
+ return;
+ }
+ Component component = getCurrentUI();
+
+ try {
+ if (!closeUI(component)) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing node canceled!");
+ }
+ // can not changed current node
+ return;
+ }
+ } catch (Exception ex) {
+ treateError(ex);
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will select path " + path);
+ }
+ // ok can safely select the new path
+ super.setSelectionPath(path);
+ }
+
+ protected void selectNodeUI(NavigationTreeNode node) {
+
+ try {
+
+ String path = node.getFullPath();
+
+ if (log.isTraceEnabled()) {
+ log.trace(path);
+ }
+
+ Component newUI = getUI(node);
+
+ // now, we are free to open the ui associated with the selected node in navigation
+
+ // get the bean associated with the node
+ Object data = getNavigationTreeModel().getBean(path);
+
+ // save it in context (must be done before init ui)
+ addSelectedBeanInContext(node, data);
+
+ if (newUI == null) {
+
+ // a new ui instance is required
+ newUI = createUI(node);
+ }
+
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // save in context current node context path
+ helper.setSelectedPath(ctxt, node.getFullPath());
+
+ // save in context current node
+ helper.setSelectedNode(ctxt, node);
+
+ // really open the ui associated with the selected node
+ openUI(newUI, node);
+
+ } catch (Exception e) {
+ // remove data from context
+
+ // if any error, go back to previvous node
+ treateError(e);
+ }
+ }
+
+ /**
+ * Prepare le context a utiliser pour initialiser une nouvelle ui.
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return le context à utiliser pour instancier l'ui
+ * @throws Exception if any
+ */
+ protected JAXXContext createUIContext(NavigationTreeNode node) throws Exception {
+
+ if (node.getUIHandlerClass() == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("no action associated with ui " + node.getUIClass());
+ }
+ // no action associated, just
+ return getContext();
+ }
+
+ JAXXAction action = node.getUIHandlerClass().newInstance();
+
+ // init context with
+ JAXXInitialContext uiContext = action.init(getContext());
+ return uiContext;
+ }
+
+ protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass()));
+ }
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // remove previous selected bean
+ //TODO-TC-20091004 should have an automatic clean context method while
+ // quiting a node ?
+ helper.setSelectedBean(ctxt, null);
+
+ if (data != null) {
+
+ helper.setSelectedBean(ctxt, data);
+ //FIXME-TC-20091004 : should really remove this, this is not context safe
+ //todo should we not use this to avoid conflict in context ?
+ //context.setContextValue(data);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,100 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JPanel;
+import java.awt.Component;
+
+/**
+ * Simple {@link NavigationTreeHandler} implementation with a {@link CardLayout2} to manage components to
+ * associated with tree's nodes.
+ * <p/>
+ * For each node, the ui associated has a constraints in a cardlayout which is the node context path.
+ * <p/>
+ * A single container managed by the cardlayout is used to display the components associated with tree's nodes.
+ *
+ * @author chemit
+ */
+public abstract class NavigationTreeHandlerWithCardLayout extends NavigationTreeHandler {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class);
+
+ /**
+ * All components associated with a tree's node is displayed in a single container.
+ *
+ * @return the containter of components
+ */
+ protected abstract JPanel getContentContainer();
+
+ /**
+ * the cardlayout managing components associated with tree node. The constraints
+ * of each component is the node contextPath.
+ *
+ * @return the layout used to display components associated with tree's nodes.
+ */
+ protected abstract CardLayout2 getContentLayout();
+
+ public NavigationTreeHandlerWithCardLayout(String contextPrefix, JAXXObject context, Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ if (getContentContainer() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context);
+ }
+ if (getContentLayout() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context);
+ }
+ }
+
+ @Override
+ protected Component getCurrentUI() {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ return layout.getVisibleComponent(container);
+ }
+
+ @Override
+ protected Component getUI(NavigationTreeNode node) {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ String constraints = strategy.getId(node);
+ return layout.contains(constraints) ? layout.getComponent(container, constraints) : null;
+ }
+
+ @Override
+ protected void openUI(Component newUI, NavigationTreeNode node) throws Exception {
+
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ // switch layout
+ String constraints = strategy.getId(node);
+ layout.show(container, constraints);
+ }
+
+ @Override
+ protected boolean closeUI(Component component) throws Exception {
+ // by default, we says that component was succesfull closed
+ return true;
+ }
+
+ @Override
+ protected Component createUI(NavigationTreeNode node) throws Exception {
+
+ JAXXContext uiContext = createUIContext(node);
+
+ JAXXObject newUI = node.getUIClass().getConstructor(JAXXContext.class).newInstance(uiContext);
+
+ if (log.isDebugEnabled()) {
+ log.debug("instanciate new ui " + newUI);
+ }
+ String constraints = strategy.getId(node);
+ getContentContainer().add((Component) newUI, constraints);
+ return (Component) newUI;
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,141 @@
+package jaxx.runtime.swing.tree;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Pattern;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Helper object associated to a given navigation tree system.
+ *
+ * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
+ *
+ * @author chemit
+ * @since 1.7.2
+ * @see NavigationTreeModel
+ */
+public abstract class NavigationTreeHelper extends NavigationTreeContextHelper {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHelper.class);
+
+ /**
+ * Create the tree model.
+ *
+ * @param context the context to associate with fresh model
+ * @return the new model build with data from the given context
+ */
+ public abstract NavigationTreeModel createTreeModel(JAXXContext context);
+
+ /**
+ * Create the tree handler.
+ *
+ * @param context the context to associate with fresh handler
+ * @return the new handler
+ */
+ public abstract NavigationTreeHandler createTreeHandler(JAXXObject context);
+
+ public NavigationTreeHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+
+ public Object getContextValue(JAXXContext context, String path) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.getBean(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation à partir de son path.
+ *
+ * @param context le contexte applicatif
+ * @param path le path absolue du noeud dans l'arbre
+ */
+ public void selectNode(JAXXContext context, String path) {
+ NavigationTreeNode node = findNode(context, path);
+ if (log.isDebugEnabled()) {
+ log.debug(path + " :: " + node);
+ }
+ if (node != null) {
+ selectNode(context, node);
+ }
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation.
+ *
+ * @param context le contexte applicatif
+ * @param node le noeud à sélectionner dans l'arbre
+ */
+ public void selectNode(JAXXContext context, NavigationTreeNode node) {
+
+
+ NavigationTreeModel navigationModel = getSafeTreeModel(context);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ TreePath path = new TreePath(navigationModel.getPathToRoot(node));
+ JTree tree = getSafeTree(context);
+ tree.setSelectionPath(path);
+ tree.scrollPathToVisible(path);
+ }
+
+ public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException {
+ NavigationTreeModel treeModel = getTreeModel(context);
+ if (treeModel == null) {
+ throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context);
+ }
+ return treeModel;
+ }
+
+ public JTree getSafeTree(JAXXContext context) throws NullPointerException {
+ JTree tree = getTree(context);
+ if (tree == null) {
+ throw new NullPointerException("could not find tree with key " + getTreeContextEntry() + " in context " + context);
+ }
+ return tree;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,246 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Model of the tree used for a navigation tree.
+ * <p/>
+ * Il est composé de {@link NavigationTreeNode}
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeModel extends DefaultTreeModel {
+
+ static private final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see NavigationTreeNode#getNodePath()
+ * @see NavigationTreeNode#getFullPath()
+ */
+ protected final String pathSeparator;
+ /**
+ * Context to retrieve beans
+ */
+ private JAXXContext context;
+
+ public NavigationTreeModel(String pathSeparator, JAXXContext context) {
+ super(null);
+ this.pathSeparator = pathSeparator;
+ this.context = context;
+ }
+
+ @Override
+ public NavigationTreeNode getRoot() {
+ return (NavigationTreeNode) super.getRoot();
+ }
+
+ /**
+ * Search from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the root node, or <code>null</code> if not find.
+ */
+ public NavigationTreeNode findNode(String path) {
+ return findNode(getRoot(), path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, String regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, Pattern regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Search from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
+ return findNode(root, path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes)
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
+ return findNode(root, path, regex == null ? null : Pattern.compile(regex));
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
+ if (regex != null) {
+ Matcher matcher = regex.matcher(path);
+ if (!matcher.matches() || matcher.groupCount() < 1) {
+ log.warn("no matching regex " + regex + " to " + path);
+ return null;
+ }
+ path = matcher.group(1);
+ if (log.isDebugEnabled()) {
+ log.debug("matching regex " + regex + " : " + path);
+ }
+ }
+ StringTokenizer stk = new StringTokenizer(path, pathSeparator);
+ NavigationTreeNode result = root;
+ // pas the first token (matches the root node)
+ if (root.isRoot() && stk.hasMoreTokens()) {
+ String rootPath = stk.nextToken();
+ if (!rootPath.equals(root.getNodePath())) {
+ return null;
+ }
+ }
+ while (stk.hasMoreTokens()) {
+ result = result.getChild(stk.nextToken());
+ }
+ return result;
+ }
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node from given navigation path.
+ *
+ * @param navigationPath the current context path of the node
+ * @return the value associated in context with the given navigation path
+ */
+ public Object getBean(String navigationPath) {
+ Object result;
+ NavigationTreeNode node = findNode(navigationPath, (Pattern) null);
+ result = getBean(node);
+ return result;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param node the current node
+ * @return the value associated in context with the given node.
+ */
+ public Object getBean(NavigationTreeNode node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getBean(getContext());
+ }
+
+ @Override
+ public void nodeChanged(TreeNode node) {
+ nodeChanged(node, false);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ @Override
+ public void nodeStructureChanged(TreeNode node) {
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep reload
+ reload(n, true);
+ super.nodeStructureChanged(node);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ public void nodeChanged(TreeNode node, boolean deep) {
+
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
+ reload(n, deep);
+ super.nodeChanged(node);
+ }
+
+ protected void reload(NavigationTreeNode node) {
+ reload(node, false);
+ }
+
+ protected void reload(NavigationTreeNode node, boolean deep) {
+ if (node == null) {
+ return;
+ }
+ node.reload(getContext());
+
+ if (deep) {
+ Enumeration<?> childs = node.children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode o = (NavigationTreeNode) childs.nextElement();
+ reload(o, true);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,242 @@
+package jaxx.runtime.swing.tree;
+
+import java.util.Enumeration;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.decorator.Decorator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This object is design to build a {@link NavigationTreeModel}.
+ *
+ * @author chemit
+ * @since 17.2
+ */
+public class NavigationTreeModelBuilder {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModelBuilder.class);
+ /**
+ * The model dealed by the builder.
+ *
+ * <b>Note:</b> It is a good idea to keep only one instance of the model.
+ * If reset is required, should empty the model but not reinstanciate it.
+ */
+ protected NavigationTreeModel model;
+ /**
+ * default ui class to use if node does not define an ui class
+ */
+ protected Class<? extends JAXXObject> defaultUIClass;
+ /**
+ * [optional] default action class
+ */
+ protected Class<? extends JAXXAction> defaultUIHandlerClass;
+
+ public NavigationTreeModelBuilder(String pathSeparator, JAXXContext context, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass) {
+ this(defaultUIClass, defaultUIHandlerClass, new NavigationTreeModel(pathSeparator, context));
+ }
+
+ public NavigationTreeModelBuilder(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, NavigationTreeModel model) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ }
+
+ public NavigationTreeModel getModel() {
+ return model;
+ }
+
+ public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, null);
+ addI18nNodeRenderer(node, "");
+ return addChildNode(null, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, null, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
+
+ if (node.getUIClass() == null) {
+ // no ui is associated with this node, use the default one
+ node.setUIClass(defaultUIClass);
+ }
+
+ if (node.getUIHandlerClass() == null) {
+ // no ui handler associated with this node, use the default one
+ node.setUIHandlerClass(defaultUIHandlerClass);
+ }
+ if (parentNode == null) {
+ model.setRoot(node);
+ } else {
+ parentNode.add(node);
+ }
+ model.nodeStructureChanged(parentNode);
+ return node;
+ }
+
+ public NavigationTreeNode removeChildNode(NavigationTreeNode node) {
+ NavigationTreeNode parentNode = node.getParent();
+ model.removeNodeFromParent(node);
+ return parentNode;
+ }
+
+ public void addI18nNodeRenderer(NavigationTreeNode node, String libelle) {
+ node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle));
+ }
+
+ public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator) {
+ node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator));
+ }
+
+ public void addNodeJaxxClasses(
+ NavigationTreeNode node,
+ Class<? extends JAXXObject> uIClass,
+ Class<? extends JAXXAction> uIHandlerClass) {
+ node.setUIClass(uIClass);
+ node.setUIHandlerClass(uIHandlerClass);
+ }
+
+ public void printModel(NavigationTreeNode node) {
+ if (node == null) {
+ return;
+ }
+ log.info("node " + node.getFullPath() + ", jxpath: " + node.getJaxxContextEntryPath() + ", entryContextDef: " + node.getJaxxContextEntryDef());
+ if (log.isDebugEnabled()) {
+ log.debug("node userObject" + node.getUserObject());
+ log.debug("value from node " + node.getBean(getModel().getContext()));
+ log.debug("value from model " + getModel().getBean(node));
+ }
+ Enumeration<?> children = node.children();
+ while (children.hasMoreElements()) {
+ printModel((NavigationTreeNode) children.nextElement());
+ }
+ }
+
+ public static abstract class ChildBuilder<O> {
+
+ protected NavigationTreeModelBuilder builder;
+
+ protected ChildBuilder(NavigationTreeModelBuilder builder) {
+ this.builder = builder;
+ }
+
+ protected abstract void init(Class<? extends O> klass);
+
+ protected abstract Decorator<? extends O> getDecorator(O child);
+
+ protected abstract String getJXPath(O child);
+
+ protected abstract String getNavigationPath(O child);
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, java.util.Collection<? extends O> beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.isEmpty()) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, O[] beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.length == 0) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,424 @@
+package jaxx.runtime.swing.tree;
+
+import java.util.Enumeration;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Node of the {@link NavigationTreeModel}.
+ *
+ * Each node is associated with :
+ * <ul>
+ * <li> a {@code bean} coming from a {@link JAXXContext} </li>
+ * <li> a {@code uiClass} to build the associated ui </li>
+ * </ul>
+ * <p/>
+ * To retrieve the bean from the context, there is a huge logic in the
+ * method {@link #getBean(JAXXContext)}.
+ *
+ * In few words, if the {@link #jaxxContextEntryDef} is defined, it means
+ * that the object is taken from the {@code context}.
+ * <p/>
+ * Otherwise, find the first ancestor with an context entry and retrieve from
+ * here the bean.
+ * <p/>
+ * Then go down to the initial node by applying the jxpath expressions
+ * {@link #jaxxContextEntryPath} of each node on road back.
+ * <p/>
+ *
+ * To identify easly a node, each node has a {@link #path} and a
+ * {@link #fullPath} (full path from root node).
+ * <p/>
+ *
+ * To display the node we use a {@link NavigationTreeNodeRenderer} which is in
+ * fact the {@link #userObject}, the object can be synch with the bean via the
+ * {@link NavigationTreeNodeRenderer#reload(java.lang.Object)} method.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @see NavigationTreeNodeRenderer
+ * @since 1.7.2
+ */
+public class NavigationTreeNode extends DefaultMutableTreeNode {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeNode.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see #path
+ * @see #fullPath
+ */
+ protected final String pathSeparator;
+ /**
+ * The node path.
+ * <p/>
+ * Used to build the {@link #fullPath} which gives a unique identifier of the
+ * node.
+ * @see #pathSeparator
+ * @see #fullPath
+ */
+ protected String path;
+ /**
+ * The full path for the node from the rood node.
+ * <p/>
+ * This path is build by appending nodes {@link #path} from the root node
+ * to this node, between each path we introduce the {@link #pathSeparator}.
+ * <p>
+ * Exemple :
+ * <pre>
+ * root
+ * $root
+ * `-- child1
+ * `-- child2
+ * </pre>
+ * will given {@code $root/child1/child2}.
+ * @see #pathSeparator
+ * @see #path
+ */
+ protected String fullPath;
+ /**
+ * The UI class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIClass} will be used while
+ * building the model.
+ */
+ protected Class<? extends JAXXObject> uIClass;
+ /**
+ * The UI handler class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIHandlerClass} will be used
+ * while building the model.
+ */
+ protected Class<? extends JAXXAction> uIHandlerClass;
+ /**
+ * The context entry definition to retrieve the bean.
+ *
+ * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
+ * node.
+ */
+ protected JAXXContextEntryDef<?> jaxxContextEntryDef;
+ /**
+ * The jxPath to process to obtain real {@code bean} from the data retrieve
+ * in the context.
+ *
+ * <b>Note:</b> If not set -no jxpath will be apply on the bean from context.
+ */
+ protected String jaxxContextEntryPath;
+ /**
+ * The bean associated with the node ( the value can be obtain via the
+ * method {@link #getBean(JAXXContext)} or directly set via method
+ * {@link #setBean(Object)}.
+ * <p/>
+ * cache of bean associated with bean to improve performance
+ */
+ protected transient Object bean;
+ /**
+ * The type of the related bean associated with the node.
+ * <p/>
+ * Note: This type is here to override the NodeRenderer internalClass, since
+ * we could need to override this data.
+ * <p/>
+ * If this property is let to null, then we will use the NodeRenderer one
+ */
+ protected Class<?> internalClass;
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
+ this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef);
+ } else if (jaxxContextEntryDef instanceof String) {
+ this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
+ } else if (jaxxContextEntryDef != null) {
+ // wrong context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
+ }
+ }
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ /**
+ *
+ * @return the text node renderer (store in {@link #userObject} property.
+ */
+ public NavigationTreeNodeRenderer getRenderer() {
+ NavigationTreeNodeRenderer render = null;
+ Object o = getUserObject();
+ if (o != null && o instanceof NavigationTreeNodeRenderer) {
+ render = (NavigationTreeNodeRenderer) o;
+ }
+ return render;
+ }
+
+ public void setRenderer(NavigationTreeNodeRenderer renderer) {
+ // clear all cache
+ bean = null;
+ setUserObject(renderer);
+ }
+
+ public String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ public String getNodePath() {
+ return path;
+ }
+
+ public void setNodePath(String navigationPath) {
+ this.path = navigationPath;
+ }
+
+ public Class<? extends JAXXObject> getUIClass() {
+ return uIClass;
+ }
+
+ public void setUIClass(Class<? extends JAXXObject> uIClass) {
+ this.uIClass = uIClass;
+ }
+
+ public void setInternalClass(Class<?> internalClass) {
+ this.internalClass = internalClass;
+ }
+
+ public Class<? extends JAXXAction> getUIHandlerClass() {
+ return uIHandlerClass;
+ }
+
+ public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
+ this.uIHandlerClass = uIHandlerClass;
+ }
+
+ public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
+ return jaxxContextEntryDef;
+ }
+
+ public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }
+
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ public Class<?> getInternalClass() {
+ if (internalClass == null && getRenderer() != null) {
+ return getRenderer().getInternalClass();
+ }
+ return internalClass;
+ }
+
+ /** @return the fully context path of the node from the root node to this. */
+ public String getFullPath() {
+ if (fullPath == null) {
+ StringBuilder sb = new StringBuilder();
+ for (TreeNode treeNode : getPath()) {
+ NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
+ sb.append(pathSeparator).append(myNode.getNodePath());
+ }
+ fullPath = sb.substring(1);
+ }
+ return fullPath;
+ }
+
+ @Override
+ public NavigationTreeNode getChildAt(int index) {
+ return (NavigationTreeNode) super.getChildAt(index);
+ }
+
+ @Override
+ public NavigationTreeNode getParent() {
+ return (NavigationTreeNode) super.getParent();
+ }
+
+ /**
+ * @param path the name of the {@link #path} to be matched in the cild of this node.
+ * @return the child of this node with given {@link # path} value.
+ */
+ public NavigationTreeNode getChild(String path) {
+ Enumeration<?> childs = children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode son = (NavigationTreeNode) childs.nextElement();
+ if (path.equals(son.getNodePath())) {
+ return son;
+ }
+ }
+ return null;
+ }
+
+ public Object getBean() {
+ return bean;
+ }
+
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ public void reload(JAXXContext context) {
+
+ // clear bean cache
+ bean = null;
+
+ // clear context navigation cache
+ fullPath = null;
+
+ NavigationTreeNodeRenderer renderer = getRenderer();
+ if (renderer == null) {
+ // this can't be !
+ throw new NullPointerException("could not find the renderer for node " + this);
+ }
+
+ Object b = getBean(context);
+
+ renderer.reload(b);
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context to seek
+ * @return the value associated in context with the given context path
+ */
+ public Object getBean(JAXXContext context) {
+ if (bean != null) {
+ // use cached bean
+ return bean;
+ }
+ Object result;
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
+ // the node maps directly a value in context, with no jxpath resolving
+ result = getJaxxContextEntryDef().getContextValue(context);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+ // find the first ancestor node with a context def
+ NavigationTreeNode parentNode = getFirstAncestorWithDef();
+ if (parentNode == null) {
+ log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")");
+ // todo must be an error
+ // no parent found
+ return null;
+ }
+ Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("could not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+ // save in cache
+ parentNode.setBean(parentBean);
+ if (this == parentNode) {
+ // current node is the node matching the context entry value and no jxpath is found
+ return parentBean;
+ }
+ if (jaxxContextEntryPath == null) {
+ // todo must be an error
+ log.warn("must find a jaxxContextEntryPath on node (" + this + ")");
+ return null;
+ }
+ String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode);
+ if (jxpathExpression == null) {
+ /// todo must be an error
+ log.warn("could not build jxpath from node " + parentNode + " to " + this);
+ // could not retreave the jxpath...
+ return null;
+ }
+ if (jxpathExpression.startsWith("[")) {
+ // special case when we want to access a collection
+ jxpathExpression = '.' + jxpathExpression;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ result = jxcontext.getValue(jxpathExpression);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ // find a node with a direct link with the context
+ return this;
+ }
+ // the node is not linked to context
+ // seek in his parent
+ NavigationTreeNode ancestor = getParent();
+ return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
+ }
+
+ protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
+ if (parentNode == this) {
+ // reach the parent limit node, return the expr computed
+ return expr;
+ }
+ int firstIndex = expr.indexOf("..");
+ int lastIndex = expr.lastIndexOf("..");
+ if (firstIndex == -1) {
+ // this is a error, since current node is not parent limit node,
+ // we must find somewhere a way to go up in nodes
+ throw new IllegalArgumentException(expr + " should contains at least one \"..\"");
+ }
+ if (firstIndex != 0) {
+ // this is a error, the ../ must be at the beginning of the expression
+ throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr);
+ }
+ NavigationTreeNode ancestor = getParent();
+ if (firstIndex == lastIndex) {
+ // found only one go up, so must be substitute by the parent node context
+ String newExpr = expr.substring(2);
+ //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2);
+ if (getParent().equals(parentNode)) {
+ // parent node is the final parent node, so no substitution needed
+ return newExpr;
+ }
+ // ancestor must have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath == null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not ");
+ }
+ newExpr = ancestor.jaxxContextEntryPath + newExpr;
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+ // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath != null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition");
+ }
+ // substitute the last ..[/] and delegate to ancestor
+ String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2));
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,44 @@
+package jaxx.runtime.swing.tree;
+
+import javax.swing.tree.TreeCellRenderer;
+
+/**
+ * Text Renderer of a {@link NavigationTreeNode}.
+ * <p/>
+ * This object will be placed as the {@link NavigationTreeNode#userObject} of
+ * nodes.
+ * <p/>
+ *
+ * In that way, we can use the {@link #toString()} value to render the node
+ * without writing any {@link TreeCellRenderer}.
+ * <p/>
+ * To rebuild the renderer text of a node use the method {@link #reload(Object)}
+ * with the {@code bean} provides by the model for the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public interface NavigationTreeNodeRenderer extends java.io.Serializable {
+
+ /**
+ *
+ * @return the render value of the node
+ */
+ @Override
+ String toString();
+
+ /**
+ *
+ * Can override the the node internal class for display purpose.
+ *
+ * @return the type of data to be displayed.
+ */
+ Class<?> getInternalClass();
+
+ /**
+ * Reload the render value from the {@code bean} of node.
+ *
+ * @param bean the bean associated to the node to render
+ */
+ void reload(Object bean);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,53 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.decorator.Decorator;
+
+/**
+ * Decorator Renderer of a {@link NavigationTreeNode}.
+ *
+ * Apply a {@link Decorator} to the {@code bean} associated to the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Decorator
+ */
+ protected final Decorator<?> decorator;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) {
+ this.internalClass = decorator.getInternalClass();
+ this.decorator = decorator;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object bean) {
+ try {
+ text = decorator.toString(bean);
+
+ } catch (Exception e) {
+ text = "";
+ }
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,48 @@
+package jaxx.runtime.swing.tree;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * I18n label Renderer of a {@link NavigationTreeNode}.
+ *
+ * Just apply a i18n translation on the given {@link #libelle}.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Static i18n label to render
+ */
+ protected final String libelle;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererI18nImpl(String libelle) {
+ this.libelle = libelle;
+ this.internalClass = String.class;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object data) {
+ text = _(libelle);
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h1>JAXX - tree utilities</h1>
+
+ This package contains all the classes of the navigation tree framework.
+
+ <p>
+ Replace the previous framework from package
+ <code>jaxx.runtime.swing.navigation</code>
+ </p>
+ </body>
+</html>
\ No newline at end of file
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,37 @@
+package jaxx.runtime.decorator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Data {
+
+ int pos;
+ String name;
+
+ protected static List<Data> generate(int nb) {
+ List<Data> datas = new ArrayList<Data>(nb);
+ for (int i = 0; i < nb; i++) {
+ datas.add(new Data(i, "name_" + (nb - i)));
+ }
+ return datas;
+ }
+
+ Data(int pos, String name) {
+ super();
+ this.pos = pos;
+ this.name = name;
+ }
+
+ public int getPos() {
+ return pos;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return "Data{pos=" + pos + ", name=\'" + name + '\'' + '}';
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/Data.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,136 @@
+package jaxx.runtime.decorator;
+
+import jaxx.runtime.decorator.JXPathDecorator.Context;
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.JXPathDecoratorTest}).
+ */
+public class JXPathDecoratorTest {
+
+
+ protected JXPathDecorator<?> decorator;
+ protected String expected;
+ protected String result;
+
+ @After
+ public void after() {
+ decorator = null;
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullInternalClass() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(null, "hello");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace2() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "${haha${hum}");
+ }
+
+ @Test
+ public void testNullBean() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "hello");
+ expected = "hello";
+ assertEquals(expected, decorator.getExpression());
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.getTokens().length);
+
+ result = decorator.toString(null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testNoJXPath() throws Exception {
+ decorator = DecoratorUtils.newJXPathDecorator(Object.class, "hello");
+ expected = "hello";
+ assertEquals(expected, decorator.getExpression());
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.getTokens().length);
+
+ result = decorator.toString(this);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testDecorator() throws Exception {
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
+ assertEquals("%1$s - %2$d", decorator.getExpression());
+ assertDecoratorInternal();
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "${expression}${nbToken}");
+ assertEquals("%1%2", decorator.getExpression());
+ assertDecoratorInternal();
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after");
+ assertEquals("before %1$s - %2$d after", decorator.getExpression());
+ assertDecoratorInternal();
+
+ decorator = DecoratorUtils.newJXPathDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter");
+ assertEquals("before%1$s-%2$dafter", decorator.getExpression());
+ assertDecoratorInternal();
+ }
+
+ @Test
+ public void testSort() throws Exception {
+
+ List<Data> datas = Data.generate(10);
+
+ JXPathDecorator<Data> d = DecoratorUtils.newJXPathDecorator(Data.class, "${pos}$d ${name}$s");
+
+ List<Data> sortData = new ArrayList<Data>(datas);
+ DecoratorUtils.sort(d, sortData, 0);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ Collections.sort(datas, new Comparator<Data>() {
+ @Override
+ public int compare(Data o1, Data o2) {
+ return o1.name.compareTo(o2.name);
+ }
+ });
+ Context<Data> context = d.context;
+ context.setComparator(null);
+ DecoratorUtils.sort(d, sortData, 1);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ }
+
+
+ public void assertDecoratorInternal(String... tokens) {
+ assertTokens(tokens);
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ private void assertTokens(String... tokens) {
+ if (tokens.length == 0) {
+ tokens = new String[]{"expression", "nbToken"};
+ }
+ assertEquals(2, decorator.nbToken);
+ assertEquals(2, decorator.getTokens().length);
+ assertEquals(tokens[0], decorator.getTokens()[0]);
+ assertEquals(tokens[1], decorator.getTokens()[1]);
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/JXPathDecoratorTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,185 @@
+package jaxx.runtime.decorator;
+
+import org.junit.After;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author chemit
+ * @since 1.7.2 (was previously {@code jaxx.runtime.MultiJXPathDecoratorTest}).
+ */
+public class MultiJXPathDecoratorTest {
+
+ protected MultiJXPathDecorator<?> decorator;
+ protected String expected;
+ protected String result;
+
+ @After
+ public void after() {
+ decorator = null;
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNullInternalClass() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(null, "hello", "#");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha", "#");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingRightBrace2() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "${haha${hum}", "#");
+ }
+
+ @Test
+ public void testNullBean() throws Exception {
+ decorator = DecoratorUtils.newMultiJXPathDecorator(Object.class, "hello", "");
+ expected = "hello";
+ assertEquals(expected, decorator.getExpression());
+ assertEquals(0, decorator.nbToken);
+ assertEquals(0, decorator.getTokens().length);
+
+ result = decorator.toString(null);
+ assertEquals(null, result);
+ }
+
+ @Test
+ public void testMultiDecorator() throws Exception {
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - ");
+ assertEquals("%1$s - %2$d", decorator.getExpression());
+ assertDecoratorInternal();
+ assertEquals(2, decorator.contexts.length);
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s", decorator.getExpression());
+ assertTokens("nbToken", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - ");
+ assertEquals("%1$s - %2$d", decorator.getExpression());
+ assertDecoratorInternal();
+ assertEquals(2, decorator.contexts.length);
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s", decorator.getExpression());
+ assertTokens("nbToken", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testMultiDecorator2() throws Exception {
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - ");
+
+ assertEquals("%1$s - %2$d - %3$s", decorator.getExpression());
+ assertTokens("expression", "nbToken", "separator");
+ assertEquals(3, decorator.contexts.length);
+
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s - %3$s", decorator.getExpression());
+ assertTokens("nbToken", "separator", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(2);
+ assertEquals("%1$s - %2$s - %3$d", decorator.getExpression());
+ assertTokens("separator", "expression", "nbToken");
+
+ expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testMultiDecoratorWithMultiRef() throws Exception {
+
+ decorator = DecoratorUtils.newMultiJXPathDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - ");
+
+ assertEquals("%1$s - %2$d - %3$s %3$s", decorator.getExpression());
+ assertTokens("expression", "nbToken", "separator");
+ assertEquals(3, decorator.contexts.length);
+
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(1);
+ assertEquals("%1$d - %2$s %3$s - %3$s", decorator.getExpression());
+ assertTokens("nbToken", "separator", "expression");
+ expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+
+ decorator.setContextIndex(2);
+ assertEquals("%1$s %3$s - %2$s - %3$d", decorator.getExpression());
+ assertTokens("separator", "expression", "nbToken");
+
+ expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSort() throws Exception {
+
+ List<Data> datas = Data.generate(10);
+
+ MultiJXPathDecorator<Data> d = DecoratorUtils.newMultiJXPathDecorator(Data.class, "${pos}$d-${name}$s", "-");
+
+ List<Data> sortData = new ArrayList<Data>(datas);
+ DecoratorUtils.sort(d, sortData, 0);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ Collections.sort(datas, new Comparator<Data>() {
+
+ @Override
+ public int compare(Data o1, Data o2) {
+ return o1.name.compareTo(o2.name);
+ }
+ });
+ d.setContextIndex(1);
+ DecoratorUtils.sort(d, sortData, 1);
+ for (int i = 0; i < datas.size(); i++) {
+ Data data = datas.get(i);
+ Data sData = sortData.get(i);
+ assertEquals(data, sData);
+ }
+ }
+
+ public void assertDecoratorInternal(String... tokens) {
+ assertTokens(tokens);
+ expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
+ result = decorator.toString(decorator);
+ assertEquals(expected, result);
+ }
+
+ private void assertTokens(String... tokens) {
+ if (tokens.length == 0) {
+ tokens = new String[]{"expression", "nbToken"};
+ }
+ assertEquals(tokens.length, decorator.nbToken);
+ assertEquals(tokens.length, decorator.getTokens().length);
+ for (int i = 0; i < tokens.length; i++) {
+ assertEquals(tokens[i], decorator.getTokens()[i]);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/decorator/MultiJXPathDecoratorTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,377 @@
+package jaxx.runtime.swing.tree;
+
+import jaxx.runtime.DefaultJAXXContext;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Test du model de navigation.
+ *
+ * @author chemit
+ */
+public class NavigationTreeModelTest {
+
+ private static final String ROOT_CONTEXT = "$root";
+ private static final String FAKE = "-fake";
+ private static final String separator = "/";
+
+ @Test
+ public void testFindNode() throws Exception {
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, new DefaultJAXXContext(), null, null);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
+ for (int i = 0; i < 4; i++) {
+ NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null);
+ for (int j = 0; j < 4; j++) {
+ NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null);
+ for (int k = 0; k < 4; k++) {
+ builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null);
+ }
+ }
+ }
+
+ NavigationTreeModel model = builder.getModel();
+
+ NavigationTreeNode node;
+ String contextPath;
+ String currentNode;
+
+ contextPath = ROOT_CONTEXT;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, ROOT_CONTEXT, 0, node, true);
+
+ node = model.findNode(ROOT_CONTEXT + FAKE);
+ Assert.assertNull(node);
+
+ for (int i = 0; i < 4; i++) {
+ currentNode = getNodeContext(i);
+ contextPath = ROOT_CONTEXT + separator + currentNode;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, currentNode, 1, node, false);
+
+ for (int j = 0; j < 4; j++) {
+ currentNode = getNodeContext(i, j);
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, currentNode, 2, node, false);
+
+ for (int k = 0; k < 4; k++) {
+ currentNode = getNodeContext(i, j, k);
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode;
+ node = model.findNode(contextPath);
+ assertNodeEquals(contextPath, currentNode, 3, node, false);
+ }
+
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE);
+ Assert.assertNull(node);
+ }
+
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE);
+ Assert.assertNull(node);
+
+ }
+
+ }
+
+ /**
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * as a bean.
+ * <p/>
+ * Tree is like this
+ * <pre>
+ * $root +
+ * - name <-- attached to context entry : java.lang.String.class,"name"
+ * - name2 <-- attached to context entry : java.lang.String.class,"name2"
+ * - model + <-- attached to context entry : Model.class,null
+ * - name
+ * -integerValue
+ * - sons +
+ * - 0 +
+ * - name
+ * - integerValue
+ * - sons
+ * - 1 +
+ * - name
+ * - integerValue
+ * - sons
+ * - 2 +
+ * - name
+ * - integerValue
+ * - sons
+ * </pre>
+ * <p/>
+ * With this tree, we will have to results :
+ * <pre>
+ * $root.name => context.get(String.class,"name")
+ * $root.name2 => context.get(String.class,"name2")
+ * $root.model => context.get(Model.class)
+ * $root.model.name => context.get(Model.class).getName()
+ * $root.model.integerValue => context.get(Model.class).getIntegerValue()
+ * $root.model.sons => context.get(Model.class).getSons()
+ * $root.model.sons.0 => context.get(Model.class).getSons().get(0)
+ * </pre>
+ *
+ * @throws Exception if any pb
+ */
+ @Test
+ public void testGetJAXXContextValue() throws Exception {
+
+ JAXXContext context = new DefaultJAXXContext();
+ context.setContextValue("the name", "name");
+ context.setContextValue("the name2", "name2");
+
+
+ context.setContextValue(
+ new Model("modelName", 10,
+ Arrays.asList(
+ new Model("one", 1, Collections.<Model>emptyList()),
+ new Model("two", 2, Collections.<Model>emptyList()),
+ new Model("three", 3, Collections.<Model>emptyList()))));
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
+ NavigationTreeNode sonNode;
+ NavigationTreeNode sonSonNode;
+ NavigationTreeNode sonSonSonNode;
+
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
+
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
+
+ builder.build(sonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null);
+
+ sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null);
+
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null);
+
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null);
+ //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
+ sonSonNode.insert(sonSonSonNode, 2);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null);
+
+ NavigationTreeModel model = builder.getModel();
+
+ Assert.assertNull(model.getBean("$root.name" + FAKE));
+
+ testBinding(model, context, "$root/name", context.getContextValue(String.class, "name"));
+ testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2"));
+
+ Model bean = context.getContextValue(Model.class);
+
+ testBinding(model, context, "$root/model", bean);
+ testBinding(model, context, "$root/model/name", bean.getName());
+ testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/model/sons", bean.getSons());
+
+ testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName());
+ testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons());
+
+
+ testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName());
+ testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons());
+
+ testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName());
+ testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons());
+ }
+
+ /**
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * as a list.
+ * <p/>
+ * Tree is like this
+ * <pre>
+ * $root +
+ * - models + <-- attached to context entry : java.util.List.class,"models"
+ * - 0 +
+ * - name
+ * -integerValue
+ * - sons +
+ * - 0 +
+ * - name
+ * - 1 +
+ * - name
+ * - integerValue
+ * - sons
+ * - 2 +
+ * - name
+ * - integerValue
+ * - sons
+ * </pre>
+ * <p/>
+ * With this tree, we will have to results :
+ * <pre>
+ * $root.models => context.get(List.class,"models")
+ * $root.models.0 => context.get(List.class,"models").get(0)
+ * $root.models.0.name => context.get(List.class,"models").get(0).getName()
+ * </pre>
+ *
+ * @throws Exception if any pb
+ */
+ @Test
+ public void testGetBeanFromList() throws Exception {
+
+ List<Model> list = Arrays.asList(
+ new Model("entryOne", 10,
+ Arrays.asList(
+ new Model("one", 1, Collections.<Model>emptyList()),
+ new Model("two", 2, Collections.<Model>emptyList()),
+ new Model("three", 3, Collections.<Model>emptyList()))),
+ new Model("entryTwo", 20,
+ Arrays.asList(
+ new Model("2one", 1, Collections.<Model>emptyList()),
+ new Model("2two", 2, Collections.<Model>emptyList()),
+ new Model("2three", 3, Collections.<Model>emptyList()))),
+ new Model("entryThree", 30,
+ Arrays.asList(
+ new Model("3one", 1, Collections.<Model>emptyList()),
+ new Model("3two", 2, Collections.<Model>emptyList()),
+ new Model("3three", 3, Collections.<Model>emptyList()))));
+ JAXXContext context = new DefaultJAXXContext();
+ context.setContextValue(list, "models");
+
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator, context, null, null);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
+ NavigationTreeNode sonNode;
+ NavigationTreeNode sonSonNode;
+ NavigationTreeNode sonSonSonNode;
+
+ // first son is a list of models
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
+
+ // first son son is a model
+ sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null);
+
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+
+ // second son son is a model
+ sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null);
+
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
+ // third son son is a model
+ sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null);
+
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
+ NavigationTreeModel model = builder.getModel();
+
+ Model bean;
+
+ testBinding(model, context, "$root/models", list);
+
+ bean = list.get(0);
+ testBinding(model, context, "$root/models/0", bean);
+ testBinding(model, context, "$root/models/0/name", bean.getName());
+ testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/0/sons", bean.getSons());
+ testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0));
+ testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName());
+
+ bean = list.get(1);
+ testBinding(model, context, "$root/models/1", bean);
+ testBinding(model, context, "$root/models/1/name", bean.getName());
+ testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/1/sons", bean.getSons());
+
+ bean = list.get(2);
+ testBinding(model, context, "$root/models/2", bean);
+ testBinding(model, context, "$root/models/2/name", bean.getName());
+ testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/2/sons", bean.getSons());
+
+ }
+
+ protected void testBinding(NavigationTreeModel model, JAXXContext context, String contextPath, Object expected) throws Exception {
+
+ Object value;
+ value = model.getBean(contextPath);
+ Assert.assertNotNull(value);
+ Assert.assertEquals(expected, value);
+ }
+
+ protected String getNodeContext(int... context) {
+ String result = "";
+ for (int i : context) {
+ result += i;
+ }
+ return result;
+ }
+
+ protected void assertNodeEquals(String contextPath, String nodeContext, int level, NavigationTreeNode node, boolean root) {
+ //System.out.println(contextPath + " : " + (node == null ? null : node.getContextPath()));
+ Assert.assertNotNull(node);
+ Assert.assertEquals(root, node.isRoot());
+ Assert.assertEquals(level, node.getLevel());
+ Assert.assertEquals(nodeContext, node.getNodePath());
+ Assert.assertEquals(contextPath, node.getFullPath());
+ }
+
+ public static class Model {
+
+ protected String name;
+ protected int integerValue;
+ protected List<Model> sons;
+
+ public Model(String name, int integerValue, List<Model> sons) {
+ this.name = name;
+ this.integerValue = integerValue;
+ this.sons = sons;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getIntegerValue() {
+ return integerValue;
+ }
+
+ public List<Model> getSons() {
+ return sons;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name:" + name + ",integerValue:" + integerValue + ",sons: " + sons + ">";
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,70 @@
+aboutframe.about=
+aboutframe.license=
+aboutframe.ok=
+aboutframe.thirdparty=
+columnselector.action.tip=
+config.action.quit=
+config.action.quit.tip=
+config.action.reset=
+config.action.reset.tip=
+config.action.save=
+config.action.save.tip=
+config.category.saved=
+config.choice.cancel=
+config.choice.continue=
+config.choice.doNotSave=
+config.choice.ok=
+config.choice.save=
+config.defaultValue=
+config.defaultValue.tip=
+config.descrition=
+config.error.category.already.exists=
+config.error.category.not.found=
+config.key=
+config.key.tip=
+config.message.quit.invalid.category=
+config.message.quit.valid.and.modified.category=
+config.modified=
+config.no.option.selected=
+config.option.final=
+config.option.label=
+config.option.modified=
+config.title=
+config.title.need.confirm=
+config.title.will.reload.application=
+config.unmodifiable=
+config.unvalid=
+config.value=
+config.value.tip=
+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=
+i18neditor.empty.locales=
+i18neditor.popup.title=
+i18neditor.selected=
+i18neditor.unselected=
+memorywidget.memory=
+numbereditor..=
+numbereditor.0=
+numbereditor.1=
+numbereditor.2=
+numbereditor.3=
+numbereditor.4=
+numbereditor.5=
+numbereditor.6=
+numbereditor.7=
+numbereditor.8=
+numbereditor.9=
+numbereditor.action.reset.tip=
+numbereditor.action.show.tip=
+numbereditor.clearAll=
+numbereditor.clearOne=
+numbereditor.toggleSign=
+timeeditor.H=
Added: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,70 @@
+aboutframe.about=
+aboutframe.license=
+aboutframe.ok=
+aboutframe.thirdparty=
+columnselector.action.tip=
+config.action.quit=
+config.action.quit.tip=
+config.action.reset=
+config.action.reset.tip=
+config.action.save=
+config.action.save.tip=
+config.category.saved=
+config.choice.cancel=
+config.choice.continue=
+config.choice.doNotSave=
+config.choice.ok=
+config.choice.save=
+config.defaultValue=
+config.defaultValue.tip=
+config.descrition=
+config.error.category.already.exists=
+config.error.category.not.found=
+config.key=
+config.key.tip=
+config.message.quit.invalid.category=
+config.message.quit.valid.and.modified.category=
+config.modified=
+config.no.option.selected=
+config.option.final=
+config.option.label=
+config.option.modified=
+config.title=
+config.title.need.confirm=
+config.title.will.reload.application=
+config.unmodifiable=
+config.unvalid=
+config.value=
+config.value.tip=
+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=
+i18neditor.empty.locales=
+i18neditor.popup.title=
+i18neditor.selected=
+i18neditor.unselected=
+memorywidget.memory=
+numbereditor..=
+numbereditor.0=
+numbereditor.1=
+numbereditor.2=
+numbereditor.3=
+numbereditor.4=
+numbereditor.5=
+numbereditor.6=
+numbereditor.7=
+numbereditor.8=
+numbereditor.9=
+numbereditor.action.reset.tip=
+numbereditor.action.show.tip=
+numbereditor.clearAll=
+numbereditor.clearOne=
+numbereditor.toggleSign=
+timeeditor.H=
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,84 @@
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ComboBoxTest extends JaxxBaseTest {
+
+ @Test
+ public void ok() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ mojo.execute();
+ checkPattern(mojo, "swingComboBox", true, "org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.java");
+ assertNumberJaxxFiles(2);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Test
+ public void error() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ // init mojo to get alls files to treate
+ mojo.init();
+
+ assertNumberJaxxFiles(1);
+
+ mojo.setLog(new SystemStreamLog() {
+
+ @Override
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ @Override
+ public void error(Throwable error) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ //do nothing
+ }
+ });
+ Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers");
+ Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount");
+
+ fieldCompilers.setAccessible(true);
+ fieldErrorCount.setAccessible(true);
+
+
+ // execute mjo on each jaxx file to produce the error
+ for (String file : mojo.files) {
+ log.info("test bad file " + file);
+ mojo.files = new String[]{file};
+ try {
+ mojo.doAction();
+ // should never pass
+ fail();
+ } catch (MojoExecutionException e) {
+ // ok jaxx compiler failed
+ assertTrue(true);
+
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get();
+ Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor);
+ assertEquals(1, compilers.size());
+ //JAXXCompiler compiler;
+ //compiler = compilers.values().iterator().next();
+ Integer nberrors = (Integer) fieldErrorCount.get(launchor);
+ assertTrue(nberrors != null && nberrors > 0);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error/swingcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,4 @@
+
+<JComboBox id='comboBox'>
+ <item value='{_("OK")}' selected='true'/>
+</JComboBox>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.nuiton.jaxx.test</groupId>
+ <artifactId>test</artifactId>
+ <version>0</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/target/test-classes</src>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <force>true</force>
+ <verbose>true</verbose>
+ <includes>
+ <value>**/ComboBoxTest/error/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,4 @@
+
+<JAXXComboBox id='comboBox'>
+ <item value='OK' selected='true'/>
+</JAXXComboBox>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,2 @@
+
+<JComboBox id='swingComboBox'/>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml 2009-10-05 19:16:52 UTC (rev 1560)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.nuiton.jaxx.test</groupId>
+ <artifactId>test</artifactId>
+ <version>0</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/target/test-classes</src>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <force>true</force>
+ <includes>
+ <value>**/ComboBoxTest/ok/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
1
0
Author: tchemit
Date: 2009-10-05 21:15:44 +0200 (Mon, 05 Oct 2009)
New Revision: 1559
Added:
branches/jaxx-2.X/jaxx-runtime/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png
branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/
branches/jaxx-2.X/jaxx-widgets/
Removed:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/
branches/jaxx-2.X/jaxx-example/
branches/jaxx-2.X/jaxx-runtime-api/
branches/jaxx-2.X/jaxx-runtime-swing-widget/
branches/jaxx-2.X/jaxx-runtime-swing/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties
branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java
Modified:
branches/jaxx-2.X/jaxx-compiler/pom.xml
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java
branches/jaxx-2.X/jaxx-demo/pom.xml
branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
branches/jaxx-2.X/jaxx-runtime/pom.xml
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java
branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties
branches/jaxx-2.X/jaxx-swing-action/pom.xml
branches/jaxx-2.X/jaxx-widgets/pom.xml
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx
branches/jaxx-2.X/pom.xml
Log:
simplify modules + refactor NavigationTree and Decorator api + add real JComboBox tag handler (incompatible with JAXX 1.X)
Modified: branches/jaxx-2.X/jaxx-compiler/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -22,17 +22,11 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
-
+
<dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
@@ -43,8 +37,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx compiler api</description>
+ <name>JAXX Compiler</name>
+ <description>JAXX Compiler api</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -4,64 +4,29 @@
*/
package jaxx;
-import jaxx.tags.swing.JTextComponentHandler;
-import jaxx.tags.swing.JTabbedPaneHandler;
-import jaxx.tags.swing.TabHandler;
-import jaxx.tags.swing.CellHandler;
-import jaxx.tags.swing.JComboBoxHandler;
-import jaxx.tags.swing.JSliderHandler;
-import jaxx.tags.swing.RowHandler;
-import jaxx.tags.swing.JSpinnerHandler;
-import jaxx.tags.swing.TableHandler;
-import jaxx.tags.swing.JScrollPaneHandler;
-import jaxx.tags.swing.JProgressBarHandler;
-import jaxx.tags.swing.JInternalFrameHandler;
-import jaxx.tags.swing.JToolBarHandler;
-import jaxx.tags.swing.JRadioButtonHandler;
-import jaxx.tags.swing.JSplitPaneHandler;
-import jaxx.tags.swing.LocaleEditorHandler;
-import jaxx.tags.swing.JCheckBoxHandler;
-import jaxx.tags.swing.EnumEditorHandler;
-import jaxx.tags.swing.JWindowHandler;
-import jaxx.tags.swing.JAXXTabHandler;
-import jaxx.tags.swing.JPasswordFieldHandler;
-import jaxx.tags.swing.ApplicationHandler;
-import jaxx.tags.swing.JMenuHandler;
-import jaxx.tags.swing.ItemHandler;
-import jaxx.tags.swing.JListHandler;
-import jaxx.tags.swing.JPopupMenuHandler;
-import jaxx.tags.swing.JTreeHandler;
-import jaxx.tags.swing.*;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Application;
-import jaxx.runtime.swing.JAXXButtonGroup;
-import jaxx.runtime.swing.JAXXComboBox;
-import jaxx.runtime.swing.JAXXList;
-import jaxx.runtime.swing.JAXXTab;
-import jaxx.runtime.swing.JAXXTree;
-import jaxx.runtime.swing.Table;
-import jaxx.spi.Initializer;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.ColorConverter;
-import jaxx.types.GridBagConstraintsConverter;
-import jaxx.types.InsetsConverter;
-import jaxx.types.KeyStrokeConverter;
-import jaxx.types.TypeManager;
import jaxx.beaninfos.BeanInfoUtil;
-import javax.swing.*;
-import javax.swing.text.JTextComponent;
-import java.awt.Color;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
+import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.BoxedCompiledObjectDecorator;
import jaxx.compiler.CompiledObjectDecorator;
import jaxx.compiler.HelpRootCompiledObjectDecorator;
+
+import jaxx.reflect.ClassDescriptorLoader;
+
import jaxx.runtime.swing.editor.EnumEditor;
import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.spi.Initializer;
+
+import jaxx.runtime.swing.*;
+import jaxx.tags.*;
+import jaxx.tags.swing.*;
+import jaxx.types.*;
+
+import java.awt.*;
+import javax.swing.text.JTextComponent;
+import javax.swing.*;
+
public class SwingInitializer implements Initializer {
@Override
@@ -69,15 +34,21 @@
BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos");
- TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+ //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing
+ TagManager.registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), EnumEditorHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), LocaleEditorHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
- TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+ //TC-20091005 : JAXXComboBox and JComboBox are not the same
+// TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
+// TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class);
+
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -371,6 +371,7 @@
final String finalClassName = fullClassName;
registerInitializer(new Runnable() { // register an initializer which will create the CompiledObject after pass 1
+ @Override
public void run() {
DefaultObjectHandler handler = (DefaultObjectHandler) TagManager.getTagHandler(null, finalClassName, JAXXCompiler.this);
if (handler == null) {
@@ -725,15 +726,15 @@
lineNumber = lineAttr;
}
}
- File src = sourceFiles.peek();
+ File srcFile = sourceFiles.peek();
try {
- src = src.getCanonicalFile();
+ srcFile = srcFile.getCanonicalFile();
}
catch (IOException e) {
// ignore ?
}
- System.err.print(src);
+ System.err.print(srcFile);
if (lineNumber != null) {
System.err.print(":" + ((sourceFiles.size() == 1) ? Integer.parseInt(lineNumber) + lineOffset : lineOffset + 1));
}
@@ -789,17 +790,17 @@
}
public void reportError(int lineNumber, String error) {
- File src = sourceFiles.isEmpty() ? null : sourceFiles.peek();
+ File errorFile = sourceFiles.isEmpty() ? null : sourceFiles.peek();
try {
- if (src != null) {
- src = src.getCanonicalFile();
+ if (errorFile != null) {
+ errorFile = errorFile.getCanonicalFile();
}
}
catch (IOException e) {
// ignore ?
}
- System.err.print(src != null ? src.getPath() : "<unknown source>");
+ System.err.print(errorFile != null ? errorFile.getPath() : "<unknown source>");
if (lineNumber > 0) {
System.err.print(":" + lineNumber);
}
@@ -970,12 +971,12 @@
components[i].getStyleClass(), parentIndex != -1 ? descriptors[parentIndex] : null);
}
- Stylesheet stylesheet = getStylesheet();
- if (stylesheet == null) {
- stylesheet = new Stylesheet();
+ Stylesheet css = getStylesheet();
+ if (css == null) {
+ css = new Stylesheet();
}
- return new JAXXObjectDescriptor(descriptors, stylesheet);
+ return new JAXXObjectDescriptor(descriptors, css);
}
/*---------------------------------------------------------------------------------*/
@@ -1227,6 +1228,7 @@
break;
} else {
reportError("error parsing parameter list: " + parameters);
+ break;
}
default:
current.append(c);
@@ -1381,7 +1383,7 @@
}
// 1.5 adds getCanonicalName; unfortunately we can't depend on 1.5 features yet
- public static String getCanonicalName(Class clazz) {
+ public static String getCanonicalName(Class<?> clazz) {
if (clazz.isArray()) {
String canonicalName = getCanonicalName(clazz.getComponentType());
if (canonicalName != null) {
@@ -1496,14 +1498,17 @@
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setErrorListener(new ErrorListener() {
+ @Override
public void warning(TransformerException ex) throws TransformerException {
throw ex;
}
+ @Override
public void error(TransformerException ex) throws TransformerException {
throw ex;
}
+ @Override
public void fatalError(TransformerException ex) throws TransformerException {
throw ex;
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -183,9 +183,9 @@
return "";
}
if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame)
- String containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
- if (containerDelegate != null) {
- return id + '.' + containerDelegate + "().setLayout(" + valueCode + ");";
+ String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
+ if (cDelegate != null) {
+ return id + '.' + cDelegate + "().setLayout(" + valueCode + ");";
}
}
// ajout du support i18n
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -57,21 +57,17 @@
* name of a property (e.g. <code>"document"</code>).
*/
public class DefaultObjectHandler implements TagHandler {
+
/** The class that this handler provides support for. */
private ClassDescriptor beanClass;
-
/** The JAXXBeanInfo for the beanClass. */
protected JAXXBeanInfo jaxxBeanInfo;
-
/** Maps property names to their respective JAXXPropertyDescriptors. */
private Map<String, JAXXPropertyDescriptor> properties;
-
/** Maps event names to their respective JAXXEventSetDescriptors. */
private Map<String, JAXXEventSetDescriptor> events;
-
/** Maps property names to their respective ProxyEventInfos. */
private Map<String, ProxyEventInfo> eventInfos;
-
/** Maps XML tags to the CompiledObjects created from them. */
protected static Map<Element, CompiledObject> objectMap = new WeakHashMap<Element, CompiledObject>();
@@ -82,12 +78,11 @@
* normally throw something else, like <code>DocumentEvent</code>.
*/
private class ProxyEventInfo {
+
/** The name of the method or field being proxied, e.g. "getText". */
String memberName;
-
/** The "actual" event listener for the property in question, e.g. DocumentListener. */
ClassDescriptor listenerClass;
-
/**
* In cases where a different object (such as a model) is more directly responsible for
* managing the property, this is the name of the property where that object can be
@@ -97,15 +92,12 @@
* attached to the new value, and the data binding to be processed.
*/
String modelName;
-
/** The name of the method used to add the "native" event listener, e.g. "addDocumentListener". */
String addMethod;
-
/** The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". */
String removeMethod;
}
-
/**
* Creates a new <code>DefaultObjectHandler</code> which provides support for the specified class. The
* class is not actually introspected until the {@link #compileFirstPass} method is invoked.
@@ -116,7 +108,6 @@
this.beanClass = beanClass;
}
-
/**
* Performs introspection on the beanClass and stores the results.
*
@@ -147,7 +138,6 @@
}
}
-
/**
* Returns
*
@@ -157,7 +147,6 @@
return beanClass;
}
-
/**
* @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code>
* supports.
@@ -171,7 +160,6 @@
return jaxxBeanInfo;
}
-
/**
* Returns the <code>JAXXBeanInfo</code> for the specified class.
*
@@ -184,7 +172,6 @@
return JAXXIntrospector.getJAXXBeanInfo(beanClass);
}
-
/**
* Returns the type of the named property. This is the return type of the property's <code>get</code> method;
* for instance <code>JLabel</code>'s <code>text</code> property is a <code>String</code>.
@@ -209,7 +196,6 @@
throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object);
}
-
/**
* @param name ?
* @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code>
@@ -253,12 +239,10 @@
}
}
-
private static ClassDescriptor getEventClass(ClassDescriptor listenerClass) {
return listenerClass.getMethodDescriptors()[0].getParameterTypes()[0];
}
-
/**
* @param memberName name of the member
* @return an array of members on which the given property depends. For
@@ -270,7 +254,6 @@
return eventInfo == null ? null : new String[]{eventInfo.modelName};
}
-
/**
* Returns a snippet of Java code which will cause a <code>PropertyChangeListener</code> to be notified
* when the member's value changes. The <code>PropertyChangeListener</code> is provided in the form
@@ -342,7 +325,6 @@
}
}
-
public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) {
if ("getClass".equals(memberName)) {
return null;
@@ -370,8 +352,7 @@
compiler));
}
return result.toString();
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
throw new CompilerException("Internal error: " + e);
}
} else {
@@ -403,7 +384,6 @@
}
}
-
/**
* Configures the event handling for members which do not fire <code>PropertyChangeEvent</code> when
* modified. The default implementation does nothing. Subclasses should override this method to call
@@ -412,7 +392,6 @@
protected void configureProxyEventInfo() {
}
-
/**
* Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
* member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
@@ -427,11 +406,10 @@
* @param memberName the name of the field or method being proxied
* @param listenerClass the type of listener which receives events when the field or method is updated
*/
- public void addProxyEventInfo(String memberName, Class listenerClass) {
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass) {
addProxyEventInfo(memberName, listenerClass, null);
}
-
/**
* Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
* member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
@@ -453,16 +431,15 @@
* @param listenerClass the type of listener which receives events when the field or method is updated
* @param modelName the JavaBeans-style name of the model property
*/
- public void addProxyEventInfo(String memberName, Class listenerClass, String modelName) {
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass, String modelName) {
String listenerName = listenerClass.getName();
listenerName = listenerName.substring(listenerName.lastIndexOf(".") + 1);
addProxyEventInfo(memberName, listenerClass, modelName, "add" + listenerName, "remove" + listenerName);
}
-
// TODO: remove this temporary method, complete switchover to ClassDescriptors
- public void addProxyEventInfo(String memberName, Class listenerClass,
- String modelName, String addMethod, String removeMethod) {
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass,
+ String modelName, String addMethod, String removeMethod) {
try {
addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod);
} catch (ClassNotFoundException e) {
@@ -470,7 +447,6 @@
}
}
-
/**
* Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
* member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
@@ -499,7 +475,7 @@
* @param removeMethod remove method name
*/
public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass,
- String modelName, String addMethod, String removeMethod) {
+ String modelName, String addMethod, String removeMethod) {
ProxyEventInfo info = new ProxyEventInfo();
info.memberName = memberName;
info.listenerClass = listenerClass;
@@ -512,14 +488,12 @@
eventInfos.put(memberName, info);
}
-
@Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
scanAttributesForDependencies(tag, compiler);
compileChildrenFirstPass(tag, compiler);
}
-
@Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
try {
@@ -548,7 +522,6 @@
compileChildrenSecondPass(tag, compiler);
}
-
public void registerCompiledObject(Element tag, JAXXCompiler compiler) {
String id = tag.getAttribute("id");
if (id == null || id.length() == 0) {
@@ -563,7 +536,6 @@
compiler.registerCompiledObject(object);
}
-
/**
* Creates the <code>CompiledObject</code> which will represent the object created by this <code>TagHandler</code>.
*
@@ -575,7 +547,6 @@
return new CompiledObject(id, getBeanClass(), compiler);
}
-
/**
* Initializes the default settings of the object, prior to setting its attribute values. The default
* implementation does nothing.
@@ -587,7 +558,6 @@
protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) {
}
-
/**
* @param property property name to test
* @return <code>true</code> if the specified property should be inherited by child components when specified
@@ -599,7 +569,6 @@
return false;
}
-
/**
* @param name name of event
* @return <code>true</code> if the specified name has the form of an event handler attribute
@@ -609,7 +578,6 @@
return name.length() > 2 && name.startsWith("on") && Character.isUpperCase(name.charAt(2));
}
-
/**
* Scans all attributes for any dependency classes and adds them to the current compilation
* set. Called by <code>compileFirstPass()</code> (it is an error to add dependencies after
@@ -632,7 +600,7 @@
if (name.equals("javaBean")) {
//compiler.preprocessScript(value);
continue;
- }
+ }
if (name.equals("constraints") || isEventHandlerName(name)) {
compiler.preprocessScript(value); // adds dependencies as a side effect
} else if (name.equals("constructorParams")) {
@@ -645,7 +613,6 @@
}
}
-
/**
* Processes the attributes of an XML tag. Four kinds of attributes are supported: simple property values (of any
* datatype supported by {@link #convertFromString}), data binding expressions (attributes containing curly-brace
@@ -663,7 +630,7 @@
attributes.add((Attr) children.item(i));
}
Collections.sort(attributes, getAttributeComparator());
-
+
for (Attr attribute : attributes) {
String name = attribute.getName();
String value = attribute.getValue().trim();
@@ -702,7 +669,7 @@
if (name.equals("genericType")) {
//TC-20090313 check after all atributes been processed
- if (object == compiler.getRootObject() ) {
+ if (object == compiler.getRootObject()) {
compiler.setGenericType(value);
} else {
object.setGenericTypes(value.split(","));
@@ -741,7 +708,6 @@
}
}
-
/**
* Returns a <code>Comparator</code> which defines the ordering in which the tag's attributes should be processed. The
* default implementation sorts the attributes according to the order defined by the {@link #getAttributeOrdering} method.
@@ -750,6 +716,7 @@
*/
protected Comparator<Attr> getAttributeComparator() {
return new Comparator<Attr>() {
+
@Override
public int compare(Attr a, Attr b) {
int aOrder = getAttributeOrdering(a);
@@ -760,7 +727,6 @@
};
}
-
/**
* Returns the priority with which a particular attribute should be processed. Lower numbers should be processed before
* higher numbers. This value is used by the {@link #getAttributeComparator} method to define the sort ordering.
@@ -775,7 +741,6 @@
return 0;
}
-
public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) {
ClassDescriptor type = getPropertyType(object, propertyName, compiler);
String binding = compiler.processDataBindings(stringValue, type);
@@ -783,7 +748,7 @@
return "";
}
try {
- Class typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
Object value = convertFromString(propertyName, stringValue, typeClass);
return getSetPropertyCode(object.getJavaCode(), propertyName, TypeManager.getJavaCode(value), compiler);
} catch (NumberFormatException e) {
@@ -796,7 +761,6 @@
return "";
}
-
/**
* Set a single property on an object. The value may be either a simple value or contain data binding expressions.
* Simple values are first converted to the property's type using {@link #convertFromString}.
@@ -843,7 +807,7 @@
compiler.addInlineStyle(object, propertyName, false);
}
try {
- Class typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
Object value = convertFromString(propertyName, stringValue, typeClass);
setProperty(object, propertyName, value, compiler);
} catch (NumberFormatException e) {
@@ -859,17 +823,14 @@
}
}
-
public void applyStylesheets(CompiledObject object, JAXXCompiler compiler) {
applyStylesheets(object, compiler, null);
}
-
private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) {
applyStylesheets(object, compiler, overrides, true);
}
-
private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) {
try {
Stylesheet stylesheet = compiler.getStylesheet();
@@ -883,7 +844,7 @@
String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId();
CompiledObject child = new CompiledObject(id,
"((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " +
- object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))",
+ object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))",
classDescriptor,
compiler,
true);
@@ -916,15 +877,13 @@
} else if (stylesheet != null) {
StylesheetHelper.applyTo(object, compiler, stylesheet, overrides);
}
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new CompilerException(e);
} catch (IllegalArgumentException e) {
compiler.reportError(e.getMessage());
}
}
-
/**
* Adds the necessary Java code to a <code>CompiledObject</code> to add an event listener at runtime.
*
@@ -958,7 +917,6 @@
}
}
-
/**
* Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is
* just a call to the property's <code>get</code> method, but it can be arbitrarily complex.
@@ -986,7 +944,6 @@
throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
}
-
/**
* Returns a snippet of Java code which will set an object property at runtime. Typically the code is
* just a call to the property's <code>set</code> method, but it can be arbitrarily complex.
@@ -1009,7 +966,6 @@
throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
}
-
/**
* Appends Java code to a <code>CompiledObject</code> in order to implement a property assignment.
* <code>setProperty</code> is invoked in response to most XML attributes (those which are not more
@@ -1029,7 +985,6 @@
object.appendInitializationCode(getSetPropertyCode(object.getJavaCodeForProperty(name), name, TypeManager.getJavaCode(value), compiler));
}
-
/**
* Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
* example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
@@ -1074,7 +1029,6 @@
throw new NumberFormatException(value);
}
-
/**
* As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names
* for <code>int</code>-valued types.
@@ -1085,7 +1039,7 @@
* @return the converted object
* @see #constantValue
*/
- protected Object convertFromString(String key, String value, Class type) {
+ protected Object convertFromString(String key, String value, Class<?> type) {
if (type == null || type == Object.class) {
return value;
}
@@ -1100,7 +1054,6 @@
}
}
-
/**
* Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
* for each child tag.
@@ -1122,7 +1075,6 @@
}
}
-
/**
* Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
* for each child tag.
@@ -1149,7 +1101,6 @@
}
}
-
/**
* Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
* JAXXCompiler.compileFirstPass}.
@@ -1163,7 +1114,6 @@
compiler.compileFirstPass(tag);
}
-
/**
* Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
* JAXXCompiler.compileSecondPass}.
@@ -1181,4 +1131,4 @@
public String toString() {
return getClass().getName() + "[" + getBeanClass().getName() + "]";
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -53,8 +53,9 @@
private String localPart;
public QName(String namespaceURI, String localPart) {
- if (localPart == null)
+ if (localPart == null) {
throw new NullPointerException();
+ }
this.namespaceURI = namespaceURI;
this.localPart = localPart;
}
@@ -71,8 +72,9 @@
@Override
public boolean equals(Object o) {
- if (o == null || !(o instanceof QName))
+ if (o == null || !(o instanceof QName)) {
return false;
+ }
QName qname = (QName) o;
return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart());
}
@@ -101,6 +103,7 @@
* encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified
* <code>TagHandler</code> will be invoked to compile it.
*
+ * @param <T>
* @param beanClass the class to associate with a <code>TagHandler</code>
* @param handler the <code>TagHandler</code> class, which must descend from <code>DefaultObjectHandler</code>
* @throws IllegalArgumentException if the handler class does not descend from <code>DefaultObjectHandler</code>
@@ -152,6 +155,7 @@
* It is not an error to register an already-registered tag and namespace combination. The new mapping
* will replace the old mapping.
*
+ * @param <T>
* @param namespace the tag's namespace
* @param tag the simple name of the tag
* @param handler the <code>TagHandler</code> which should process the tag
@@ -385,15 +389,18 @@
* @return the resolved fqn class name
*/
public static String resolveClassName(String name, JAXXCompiler compiler) {
- if (name.endsWith("[]"))
+ if (name.endsWith("[]")) {
return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]";
- if (name.indexOf("<") != -1)
+ }
+ if (name.indexOf("<") != -1) {
name = name.substring(0, name.indexOf("<")); // strip off generic types
+ }
name = name.intern();
if (name.equals("boolean") || name.equals("byte") || name.equals("short") || name.equals("int") ||
- name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char"))
+ name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char")) {
return name;
+ }
String result = null;
String originalName = name;
@@ -452,14 +459,16 @@
// else we found a class by the same name, but in the wrong package
}
- if (dotPos <= 0)
+ if (dotPos <= 0) {
break;
+ }
dotPos = originalName.lastIndexOf('.', dotPos - 1);
}
}
- if (result != null && !result.equals(originalName))
+ if (result != null && !result.equals(originalName)) {
result = resolveClassName(result, compiler); // check for aliases against the new name as well
+ }
return result;
}
@@ -468,8 +477,9 @@
public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) {
try {
className = resolveClassName(className, compiler);
- if (className == null)
+ if (className == null) {
return null;
+ }
return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader());
}
catch (ClassNotFoundException e) {
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/EnumEditorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.tags.swing;
-
-import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultComponentHandler;
-
-import java.awt.event.ItemListener;
-import jaxx.runtime.swing.editor.EnumEditor;
-
-public class EnumEditorHandler extends DefaultComponentHandler {
-
- public EnumEditorHandler(ClassDescriptor beanClass) {
- super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, EnumEditor.class);
- }
-
- @Override
- protected void configureProxyEventInfo() {
- super.configureProxyEventInfo();
- addProxyEventInfo("getSelectedIndex", ItemListener.class);
- addProxyEventInfo("getSelectedItem", ItemListener.class);
- }
-
- @Override
- protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-// @Override
-// public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
-// super.compileChildrenSecondPass(tag, compiler);
-// CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
-// List<Item> items = list.getItems();
-// if (items != null && !items.isEmpty()) {
-// String listName = list.getId() + "$items";
-// list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
-// for (Item item : items) {
-// String id = item.getId();
-// CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
-// compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
-// compiler.registerCompiledObject(compiledItem);
-// list.appendAdditionCode(listName + ".add(" + id + ");");
-// }
-// list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
-// }
-// }
-}
-
-
-
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -24,14 +24,17 @@
public class ItemHandler implements TagHandler {
private String DATA_BINDING = "<data binding has not been processed yet>";
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
String id = tag.getAttribute("id");
- if (id == null || id.length() == 0)
+ if (id == null || id.length() == 0) {
id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class));
+ }
String label = null;
String value = null;
boolean selected = false;
@@ -47,10 +50,12 @@
}
if (name.equals(Item.LABEL_PROPERTY)) {
String labelBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(String.class));
- if (labelBinding != null)
+ if (labelBinding != null) {
compiler.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");");
- else
+ }
+ else {
label = attrValue;
+ }
continue;
}
if (name.equals(Item.VALUE_PROPERTY)) {
@@ -58,16 +63,19 @@
if (valueBinding != null) {
value = DATA_BINDING;
compiler.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");");
- } else
+ } else {
value = attrValue;
+ }
continue;
}
if (name.equals(Item.SELECTED_PROPERTY)) {
String selectedBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Boolean.class));
- if (selectedBinding != null)
+ if (selectedBinding != null) {
compiler.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");");
- else
+ }
+ else {
selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class);
+ }
continue;
}
@@ -78,8 +86,9 @@
Item item = new Item(id, label, value, selected);
CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
- if (value == null)
+ if (value == null) {
compiler.reportError("<item> tag is missing required 'value' attribute");
+ }
else {
if (!value.equals(DATA_BINDING)) {
List<Item> items = list.getItems();
@@ -108,8 +117,9 @@
} else
if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
String text = ((Text) node).getData().trim();
- if (text.length() > 0)
+ if (text.length() > 0) {
compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
}
}
}
@@ -126,8 +136,9 @@
} else
if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
String text = ((Text) node).getData().trim();
- if (text.length() > 0)
+ if (text.length() > 0) {
compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -4,26 +4,23 @@
*/
package jaxx.tags.swing;
+import java.io.IOException;
import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Item;
-import jaxx.runtime.swing.JAXXComboBox;
import jaxx.tags.DefaultComponentHandler;
-import jaxx.types.TypeManager;
-import org.w3c.dom.Element;
import java.awt.event.ItemListener;
-import java.io.IOException;
-import java.util.List;
+import javax.swing.JComboBox;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
public class JComboBoxHandler extends DefaultComponentHandler {
public JComboBoxHandler(ClassDescriptor beanClass) {
super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class);
}
@Override
@@ -34,26 +31,10 @@
}
@Override
- protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-
- @Override
public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
- super.compileChildrenSecondPass(tag, compiler);
- CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
- List<Item> items = list.getItems();
- if (items != null && !items.isEmpty()) {
- String listName = list.getId() + "$items";
- list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
- for (Item item : items) {
- String id = item.getId();
- CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
- compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
- compiler.registerCompiledObject(compiledItem);
- list.appendAdditionCode(listName + ".add(" + id + ");");
- }
- list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JComboBox does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -17,29 +17,32 @@
import javax.swing.event.ChangeListener;
public class JSliderHandler extends DefaultComponentHandler {
+
public JSliderHandler(ClassDescriptor beanClass) {
super(beanClass);
- if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass))
+ if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass)) {
throw new IllegalArgumentException(getClass().getName() + " does not support the class " + beanClass.getName());
+ }
}
-
+ @Override
protected int getAttributeOrdering(Attr attr) {
- if (attr.getName().equals("value"))
+ if (attr.getName().equals("value")) {
return 1;
- else
+ } else {
return super.getAttributeOrdering(attr);
+ }
}
-
- protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
super.setDefaults(object, tag, compiler);
setAttribute(object, "value", "0", false, compiler);
}
-
+ @Override
protected void configureProxyEventInfo() {
super.configureProxyEventInfo();
addProxyEventInfo("getValue", ChangeListener.class, "model");
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -53,7 +53,7 @@
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
super.compileSecondPass(tag, compiler);
CompiledObject object = objectMap.get(tag);
- Map properties = object.getProperties();
+ Map<?,?> properties = object.getProperties();
if (!properties.containsKey("width") && !properties.containsKey("height")) {
compiler.appendLateInitializer(object.getId() + ".pack();\n");
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/LocaleEditorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,56 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.tags.swing;
-
-import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultComponentHandler;
-
-import java.awt.event.ItemListener;
-import jaxx.runtime.swing.editor.LocaleEditor;
-
-public class LocaleEditorHandler extends DefaultComponentHandler {
-
- public LocaleEditorHandler(ClassDescriptor beanClass) {
- super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, LocaleEditor.class);
- }
-
- @Override
- protected void configureProxyEventInfo() {
- super.configureProxyEventInfo();
- addProxyEventInfo("getSelectedIndex", ItemListener.class);
- addProxyEventInfo("getSelectedItem", ItemListener.class);
- }
-
- @Override
- protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-// @Override
-// public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
-// super.compileChildrenSecondPass(tag, compiler);
-// CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
-// List<Item> items = list.getItems();
-// if (items != null && !items.isEmpty()) {
-// String listName = list.getId() + "$items";
-// list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
-// for (Item item : items) {
-// String id = item.getId();
-// CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
-// compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
-// compiler.registerCompiledObject(compiledItem);
-// list.appendAdditionCode(listName + ".add(" + id + ");");
-// }
-// list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
-// }
-// }
-}
-
-
-
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -18,10 +18,13 @@
import java.io.IOException;
public class RowHandler implements TagHandler {
+
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (!ClassDescriptorLoader.getClassDescriptor(Table.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
compiler.reportError("row tag may only appear within Table tag");
@@ -82,4 +85,4 @@
protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compiler.compileSecondPass(tag);
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -26,11 +26,13 @@
public class TabHandler implements TagHandler {
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (!ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
compiler.reportError("tab tag may only appear within JTabbedPane tag");
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -11,7 +11,7 @@
import jaxx.introspection.JAXXPropertyDescriptor;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.tags.DefaultObjectHandler;
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -25,6 +25,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(ExcludeFieldValidatorHandler.class);
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.info(tag);
@@ -32,6 +33,7 @@
//todo check there is no child
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.debug(tag);
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -25,6 +25,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(FieldValidatorHandler.class);
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.info(tag);
@@ -32,6 +33,7 @@
//todo check there is no child
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
if (compiler.getOptions().isVerbose()) {
log.info(tag);
Modified: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -21,7 +21,7 @@
BeanInfoUtil.reset();
Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length);
- String packageName = getClass().getPackage().getName()+".dummy";
+ String packageName = getClass().getPackage().getName() + ".dummy";
BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName);
searchPath = Introspector.getBeanInfoSearchPath();
Modified: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -135,8 +135,10 @@
@Test
public void testAliasing() {
- Assert.assertEquals("JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("JComboBox", compiler));
- Assert.assertEquals("javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("javax.swing.JComboBox", compiler));
+ Assert.assertEquals("ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("ButtonGroup", compiler));
+ Assert.assertEquals("javax.swing.ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("javax.swing.ButtonGroup", compiler));
+// Assert.assertEquals("JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("JComboBox", compiler));
+// Assert.assertEquals("javax.swing.JComboBox is not aliased to jaxx.runtime.swing.JAXXComboBox", "jaxx.runtime.swing.JAXXComboBox", TagManager.resolveClassName("javax.swing.JComboBox", compiler));
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,394 +0,0 @@
-package jaxx.runtime.swing.navigation;
-
-import jaxx.runtime.swing.navigation.*;
-import jaxx.runtime.DefaultJAXXContext;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXContextEntryDef;
-import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-
-/**
- * Test du model de navigation.
- *
- * @author chemit
- */
-public class NavigationTreeModelTest {
-
- private static final String ROOT_CONTEXT = "$root";
- private static final String FAKE = "-fake";
-
- private static final String separator = "/";
-
- @Test
- public void testFindNode() throws Exception {
-
- NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
-
- NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
-
- for (int i = 0; i < 4; i++) {
- NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null);
- for (int j = 0; j < 4; j++) {
- NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null);
- for (int k = 0; k < 4; k++) {
- builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null);
- }
- }
- }
-
- NavigationTreeModel model = builder.getModel();
-
- NavigationTreeNode node;
- String contextPath;
- String currentNode;
-
- contextPath = ROOT_CONTEXT;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, ROOT_CONTEXT, 0, node, true);
-
- node = model.findNode(ROOT_CONTEXT + FAKE);
- Assert.assertNull(node);
-
- for (int i = 0; i < 4; i++) {
- currentNode = getNodeContext(i);
- contextPath = ROOT_CONTEXT + separator + currentNode;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, currentNode, 1, node, false);
-
- for (int j = 0; j < 4; j++) {
- currentNode = getNodeContext(i, j);
- contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, currentNode, 2, node, false);
-
- for (int k = 0; k < 4; k++) {
- currentNode = getNodeContext(i, j, k);
- contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode;
- node = model.findNode(contextPath);
- assertNodeEquals(contextPath, currentNode, 3, node, false);
- }
-
- node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE);
- Assert.assertNull(node);
- }
-
- node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE);
- Assert.assertNull(node);
-
- }
-
- }
-
- /**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
- * as a bean.
- * <p/>
- * Tree is like this
- * <pre>
- * $root +
- * - name <-- attached to context entry : java.lang.String.class,"name"
- * - name2 <-- attached to context entry : java.lang.String.class,"name2"
- * - model + <-- attached to context entry : Model.class,null
- * - name
- * -integerValue
- * - sons +
- * - 0 +
- * - name
- * - integerValue
- * - sons
- * - 1 +
- * - name
- * - integerValue
- * - sons
- * - 2 +
- * - name
- * - integerValue
- * - sons
- * </pre>
- * <p/>
- * With this tree, we will have to results :
- * <pre>
- * $root.name => context.get(String.class,"name")
- * $root.name2 => context.get(String.class,"name2")
- * $root.model => context.get(Model.class)
- * $root.model.name => context.get(Model.class).getName()
- * $root.model.integerValue => context.get(Model.class).getIntegerValue()
- * $root.model.sons => context.get(Model.class).getSons()
- * $root.model.sons.0 => context.get(Model.class).getSons().get(0)
- * </pre>
- *
- * @throws Exception if any pb
- */
- @Test
- public void testGetJAXXContextValue() throws Exception {
-
- NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
-
- NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
-
- NavigationTreeNode sonNode;
- NavigationTreeNode sonSonNode;
- NavigationTreeNode sonSonSonNode;
-
- builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
- builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
-
- sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
-
- builder.build(sonNode, (String) null, "../name", "name", null, null);
- builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null);
-
- sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null);
-
- builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null);
-
- builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null);
- //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
- sonSonNode.insert(sonSonSonNode, 2);
- builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null);
- builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null);
- builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null);
-
- NavigationTreeModel model = builder.getModel();
-
- JAXXContext context = new DefaultJAXXContext();
- context.setContextValue("the name", "name");
- context.setContextValue("the name2", "name2");
-
-
- context.setContextValue(
- new Model("modelName", 10,
- Arrays.asList(
- new Model("one", 1, Collections.<Model>emptyList()),
- new Model("two", 2, Collections.<Model>emptyList()),
- new Model("three", 3, Collections.<Model>emptyList())
- )
- )
- );
-
- Assert.assertNull(model.getJAXXContextValue(context, "$root.name" + FAKE));
-
- testBinding(model, context, "$root/name", context.getContextValue(String.class, "name"));
- testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2"));
-
- Model bean = context.getContextValue(Model.class);
-
- testBinding(model, context, "$root/model", bean);
- testBinding(model, context, "$root/model/name", bean.getName());
- testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/model/sons", bean.getSons());
-
- testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName());
- testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue());
- testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons());
-
-
- testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName());
- testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue());
- testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons());
-
- testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName());
- testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue());
- testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons());
- }
-
- /**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
- * as a list.
- * <p/>
- * Tree is like this
- * <pre>
- * $root +
- * - models + <-- attached to context entry : java.util.List.class,"models"
- * - 0 +
- * - name
- * -integerValue
- * - sons +
- * - 0 +
- * - name
- * - 1 +
- * - name
- * - integerValue
- * - sons
- * - 2 +
- * - name
- * - integerValue
- * - sons
- * </pre>
- * <p/>
- * With this tree, we will have to results :
- * <pre>
- * $root.models => context.get(List.class,"models")
- * $root.models.0 => context.get(List.class,"models").get(0)
- * $root.models.0.name => context.get(List.class,"models").get(0).getName()
- * </pre>
- *
- * @throws Exception if any pb
- */
- @Test
- public void testGetJAXXContextValueFromList() throws Exception {
-
- NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
-
- NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
-
- NavigationTreeNode sonNode;
- NavigationTreeNode sonSonNode;
- NavigationTreeNode sonSonSonNode;
-
- // first son is a list of models
- sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
-
- // first son son is a model
- sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null);
-
- builder.build(sonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
-
- sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null);
- builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
-
- // second son son is a model
- sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null);
-
- builder.build(sonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
-
- // third son son is a model
- sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null);
-
- builder.build(sonSonNode, (String) null, "../name", "name", null, null);
- builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
- builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
-
- NavigationTreeModel model = builder.getModel();
-
-
- List<Model> list = Arrays.asList(
- new Model("entryOne", 10,
- Arrays.asList(
- new Model("one", 1, Collections.<Model>emptyList()),
- new Model("two", 2, Collections.<Model>emptyList()),
- new Model("three", 3, Collections.<Model>emptyList())
- )
- ),
- new Model("entryTwo", 20,
- Arrays.asList(
- new Model("2one", 1, Collections.<Model>emptyList()),
- new Model("2two", 2, Collections.<Model>emptyList()),
- new Model("2three", 3, Collections.<Model>emptyList())
- )
- ),
- new Model("entryThree", 30,
- Arrays.asList(
- new Model("3one", 1, Collections.<Model>emptyList()),
- new Model("3two", 2, Collections.<Model>emptyList()),
- new Model("3three", 3, Collections.<Model>emptyList())
- )
- )
- );
- JAXXContext context = new DefaultJAXXContext();
- context.setContextValue(list, "models");
-
- Model bean;
-
- testBinding(model, context, "$root/models", list);
-
- bean = list.get(0);
- testBinding(model, context, "$root/models/0", bean);
- testBinding(model, context, "$root/models/0/name", bean.getName());
- testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/models/0/sons", bean.getSons());
- testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0));
- testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName());
-
- bean = list.get(1);
- testBinding(model, context, "$root/models/1", bean);
- testBinding(model, context, "$root/models/1/name", bean.getName());
- testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/models/1/sons", bean.getSons());
-
- bean = list.get(2);
- testBinding(model, context, "$root/models/2", bean);
- testBinding(model, context, "$root/models/2/name", bean.getName());
- testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root/models/2/sons", bean.getSons());
-
- }
-
- protected void testBinding(NavigationTreeModel model, JAXXContext context, String contextPath, Object expected) throws Exception {
-
- Object value;
- value = model.getJAXXContextValue(context, contextPath);
- Assert.assertNotNull(value);
- Assert.assertEquals(expected, value);
- }
-
- protected String getNodeContext(int... context) {
- String result = "";
- for (int i : context) {
- result += i;
- }
- return result;
- }
-
- protected void assertNodeEquals(String contextPath, String nodeContext, int level, NavigationTreeNode node, boolean root) {
- //System.out.println(contextPath + " : " + (node == null ? null : node.getContextPath()));
- Assert.assertNotNull(node);
- Assert.assertEquals(root, node.isRoot());
- Assert.assertEquals(level, node.getLevel());
- Assert.assertEquals(nodeContext, node.getNavigationPath());
- Assert.assertEquals(contextPath, node.getContextPath());
- }
-
- public static class Model {
-
- protected String name;
-
- protected int integerValue;
-
- protected List<Model> sons;
-
- public Model(String name, int integerValue, List<Model> sons) {
- this.name = name;
- this.integerValue = integerValue;
- this.sons = sons;
- }
-
- public String getName() {
- return name;
- }
-
- public int getIntegerValue() {
- return integerValue;
- }
-
- public List<Model> getSons() {
- return sons;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<name:" + name + ",integerValue:" + integerValue + ",sons: " + sons + ">";
- }
- }
-
-}
Modified: branches/jaxx-2.X/jaxx-demo/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -22,12 +22,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing-widget</artifactId>
+ <artifactId>jaxx-widgets</artifactId>
<version>${project.version}</version>
</dependency>
@@ -35,7 +35,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<classifier>tests</classifier>
@@ -52,8 +52,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx Demo module</description>
+ <name>JAXX Demo</name>
+ <description>JAXX Demo</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
Modified: branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,6 +1,9 @@
application.name=${project.name}
application.version=${project.version}
application.site.url=http://maven-site.nuiton.org/jaxx/jaxx-example
+application.icon.path=/icons/jaxx.png
+application.license.path=META-INF/${project.artifactId}-LICENSE.txt
+application.third-party.path=META-INF/${project.artifactId}-THIRD-PARTY.txt
#licence.name=${project.licenses[0].license.name}
#licence.url=${project.licenses.0.url}
application.organisation.name=${project.organization.name}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,87 +1,110 @@
-
-<JTabbedPane id='top'>
-
- <script><![CDATA[
-import org.apache.commons.io.IOUtils;
-
-protected String[] getSources() {
- if (getClass() == DemoPanel.class) {
- return new String[0];
- }
- return new String[]{ getDefaultSource() };
-}
-
-protected String getDefaultSource() {
- return getClass().getSimpleName() + ".jaxx";
-}
-
-public String getLabel() {
- String name = getClass().getSimpleName();
- if (name.endsWith("Demo")) {
- name = name.substring(0, name.length() - "Demo".length());
- }
- return name;
-}
-
-public String getDemoTabTitle() {
- return getLabel() + " Demo";
-}
-
-public String loadSource(String filename) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(filename + " from " + getClass());
- }
- String result = IOUtils.toString(getClass().getResourceAsStream(filename));
-
- return result;
- } catch (Exception e) {
- log.error("could not load file " + filename, e);
- return "could not load file " + filename;
- }
-}
-
-private void $afterCompleteSetup() {
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- if (getSources().length == 0) {
- top.remove(sourceTabs);
- return;
- }
- for (String extra : getSources()) {
- JScrollPane pane = new JScrollPane(
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- pane.setBorder(null);
- // creation du contenu du fichier
- JTextArea content = new JTextArea();
- content.setFont(content.getFont().deriveFont((float) 11));
- content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
- content.setEditable(false);
- content.setWrapStyleWord(false);
- content.setText(loadSource(extra));
- content.setColumns(80);
- pane.getViewport().add(content);
- // ajout de l'onglet
- sourceTabs.addTab(extra, pane);
- int index = sourceTabs.indexOfComponent(pane);
- JLabel l = new JLabel(extra);
- l.setFont(l.getFont().deriveFont((float) 10));
- sourceTabs.setTabComponentAt(index,l);
- }
- }
- });
-}
- ]]>
- </script>
-
- <tab title='{getDemoTabTitle()}'>
- <JPanel id='demoPanel'/>
- </tab>
-
- <tab title='Sources'>
- <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
- </tab>
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<JTabbedPane id='top'>
+
+ <script><![CDATA[
+import org.apache.commons.io.IOUtils;
+
+protected String[] getSources() {
+ if (getClass() == DemoPanel.class) {
+ return new String[0];
+ }
+ return new String[]{ getDefaultSource() };
+}
+
+protected String getDefaultSource() {
+ return getClass().getSimpleName() + ".jaxx";
+}
+
+public String getLabel() {
+ String name = getClass().getSimpleName();
+ if (name.endsWith("Demo")) {
+ name = name.substring(0, name.length() - "Demo".length());
+ }
+ return name;
+}
+
+public String getDemoTabTitle() {
+ return getLabel() + " Demo";
+}
+
+public String loadSource(String filename) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(filename + " from " + getClass());
+ }
+ String result = IOUtils.toString(getClass().getResourceAsStream(filename));
+
+ return result;
+ } catch (Exception e) {
+ log.error("could not load file " + filename, e);
+ return "could not load file " + filename;
+ }
+}
+
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (getSources().length == 0) {
+ top.remove(sourceTabs);
+ return;
+ }
+ for (String extra : getSources()) {
+ JScrollPane pane = new JScrollPane(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ pane.setBorder(null);
+ //pane.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
+ // creation du contenu du fichier
+ JTextArea content = new JTextArea();
+ content.setFont(content.getFont().deriveFont((float) 11));
+ content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
+ content.setEditable(false);
+ content.setWrapStyleWord(false);
+ content.setText(loadSource(extra));
+ content.setColumns(80);
+ content.setLineWrap(true);
+ pane.getViewport().add(content);
+ content.setCaretPosition(0);
+ // ajout de l'onglet
+ sourceTabs.addTab(extra, pane);
+ int index = sourceTabs.indexOfComponent(pane);
+ JLabel l = new JLabel(extra);
+ l.setFont(l.getFont().deriveFont((float) 10));
+ sourceTabs.setTabComponentAt(index,l);
+ }
+ }
+ });
+}
+ ]]>
+ </script>
+
+ <tab title='{getDemoTabTitle()}'>
+ <JPanel id='demoPanel'/>
+ </tab>
+
+ <tab title='Sources'>
+ <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
+ </tab>
</JTabbedPane>
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -25,8 +25,8 @@
import jaxx.demo.component.swing.*;
import jaxx.demo.component.jaxx.*;
import jaxx.demo.component.jaxx.editor.*;
-import jaxx.demo.component.jaxx.navigation.full.FullNavigationTreeDemo;
import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
+import jaxx.demo.component.jaxx.tree.FullNavigationTreeDemo;
import jaxx.demo.feature.databinding.BeanDataBindingDemo;
import jaxx.demo.feature.validation.*;
import jaxx.demo.fun.*;
@@ -38,13 +38,8 @@
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.navigation.NavigationTreeModel;
-import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
-import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
-import jaxx.runtime.swing.navigation.NavigationTreeHandler;
-import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
-import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
-import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.tree.*;
+import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -67,7 +62,7 @@
log.debug("start creating demo model");
}
- TreeModelBuilder builder = new TreeModelBuilder();
+ TreeModelBuilder builder = new TreeModelBuilder(context);
builder.addText(n_("jaxxdemo.tree.component.swing")).
addText(n_("jaxxdemo.tree.component.swing.buttons")).
@@ -121,6 +116,7 @@
addDemo(ValidationListDemo.class).
addDemo(ValidationTableDemo.class).
goUp().
+ goUp().
addText(n_("jaxxdemo.tree.fun")).
addDemo(LabelStyleDemo.class).
addDemo(CounterDemo.class).
@@ -129,7 +125,7 @@
NavigationTreeModel model = builder.getModel();
if (log.isDebugEnabled()) {
- builder.printModel(context, model.getRoot());
+ builder.printModel(model.getRoot());
}
// save tree model in context
setTreeModel(context, model);
@@ -139,10 +135,10 @@
@Override
public NavigationTreeHandler createTreeHandler(JAXXObject context) {
- NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout(
+ NavigationTreeHandler handler;
+
+ handler = new NavigationTreeHandlerWithCardLayout(
getPrefix(),
- DemoPanel.class,
- null,
context,
Strategy.PER_UI_TYPE) {
@@ -168,7 +164,8 @@
ErrorDialogUI.showError(e);
}
- protected DemoUI getContext() {
+ @Override
+ public DemoUI getContext() {
return (DemoUI) context;
}
};
@@ -189,34 +186,34 @@
/**
* la pile des noeuds parent
*/
- protected Stack<NavigationTreeNode> parentNodes;
+ protected Stack<NavigationTreeNode> nodes;
- protected TreeModelBuilder() {
- super("/");
- parentNodes = new Stack<NavigationTreeNode>();
- parentNodes.add(buildEmptyRoot(def, "$root"));
+ protected TreeModelBuilder(JAXXContext context) {
+ super("/", context, DemoPanel.class, null);
+ nodes = new Stack<NavigationTreeNode>();
+ nodes.add(buildEmptyRoot(def, "$root"));
}
protected TreeModelBuilder goUp() {
- parentNodes.pop();
+ nodes.pop();
return this;
}
protected TreeModelBuilder addText(String label) {
- NavigationTreeNode parentNode = parentNodes.peek();
+ NavigationTreeNode parentNode = nodes.peek();
parentNode = build(parentNode, label, def, label, null, null);
if (log.isDebugEnabled()) {
- log.debug(label + " [" + parentNode.getContextPath() + "]");
+ log.debug(label + " [" + parentNode.getFullPath() + "]");
}
- parentNodes.push(parentNode);
+ nodes.push(parentNode);
return this;
}
protected TreeModelBuilder addDemo(Class<? extends DemoPanel> demoClass) {
- NavigationTreeNode parentNode = parentNodes.peek();
+ NavigationTreeNode parentNode = nodes.peek();
String label = demoClass.getSimpleName();
if (log.isDebugEnabled()) {
- log.debug(label + " [" + parentNode.getContextPath() + "]");
+ log.debug(label + " [" + parentNode.getFullPath() + "]");
}
build(parentNode, label, def, label, demoClass, null);
return this;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-05 19:15:44 UTC (rev 1559)
@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
- */
+*/
JToolBar {
borderPainted:false;
floatable:false;
@@ -28,6 +28,12 @@
dividerSize:6;
}
+#mainFrame {
+ title:"JAXX Demo";
+ iconImage:{jaxx.runtime.SwingUtil.createIcon(getConfig().getOption("application.icon.path")).getImage()};
+ undecorated:{getConfig().isFullScreen()};
+}
+
#menu {
_help:{"ui.main.menu"};
}
@@ -61,8 +67,8 @@
toolTipText:"jaxxdemo.action.locale.fr.tip";
actionIcon:"i18n-fr";
enabled:{!acceptLocale(getConfig().getLocale(), "fr_FR")};
- mnemonic:F;
- _help:{"ui.main.menu.file.locale.fr"};
+mnemonic:F;
+_help:{"ui.main.menu.file.locale.fr"};
}
#menuFileLanguageUK {
@@ -70,8 +76,8 @@
toolTipText:"jaxxdemo.action.locale.uk.tip";
actionIcon:"i18n-uk";
enabled:{!acceptLocale(getConfig().getLocale(), "en_GB")};
- mnemonic:U;
- _help:{"ui.main.menu.file.locale.uk"};
+mnemonic:U;
+_help:{"ui.main.menu.file.locale.uk"};
}
#menuFileFullscreen {
@@ -80,7 +86,7 @@
actionIcon:"fullscreen";
mnemonic:P;
visible:{!isUndecorated()};
- _help:{"ui.main.menu.file.fullscreen"};
+_help:{"ui.main.menu.file.fullscreen"};
}
#menuFileNormalscreen {
@@ -89,7 +95,7 @@
actionIcon:"leave-fullscreen";
mnemonic:N;
visible:{isUndecorated()};
- _help:{"ui.main.menu.file.leave-fullscreen"};
+_help:{"ui.main.menu.file.leave-fullscreen"};
}
#menuFileExit{
@@ -137,17 +143,24 @@
visible:true;
}
+#navigationPane{
+ border:{null};
+minimumSize:{new Dimension(230,0)};
+horizontalScrollBarPolicy:{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER};
+}
+
#navigation{
rootVisible:false;
+ showsRootHandles:false;
largeModel:true;
font-size:11;
}
-/*
+
#splitpane{
orientation:{JSplitPane.HORIZONTAL_SPLIT};
_help:{"ui.main.body.db"};
resizeWeight:1.0;
-}*/
+}
#contentLayout{
useOnlyVisibleComponentDimension:true;
@@ -155,7 +168,7 @@
#content{
layout:{contentLayout};
- _help:{"ui.main.body.db.view.content"};
+_help:{"ui.main.body.db.view.content"};
}
/*
#toolbar {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,81 +1,113 @@
-
-<JFrame id='mainFrame'
- title="JAXX Demo"
- width='1024'
- height='800'
- decorator='help'
- undecorated='{getConfig().isFullScreen()}'
- onWindowClosing='getHandler().close(mainFrame)'>
-
- <style source='DemoUI.css'/>
-
- <jaxx.runtime.swing.CardLayout2 id='contentLayout'/>
-
- <script><![CDATA[
-import jaxx.runtime.swing.navigation.*;
-import java.util.Locale;
-
-public DemoConfig getConfig() {
- return getContextValue(DemoConfig.class);
-}
-
-protected DemoUIHandler getHandler() {
- return getContextValue(DemoUIHandler.class);
-}
-
-protected DemoTreeHelper getTreeHelper() {
- return getContextValue(DemoTreeHelper.class);
-}
-
-public boolean acceptLocale(Locale l, String expected) {
- return l !=null && l.toString().equals(expected);
-}
-
-]]>
- </script>
-
- <JMenuBar id='menu'>
-
- <JMenu id='menuFile'>
- <JMenuItem id='menuFileConfiguration'
- onActionPerformed="getHandler().showConfig(this)"/>
- <JMenu id='menuFileLanguage'>
- <JMenuItem id='menuFileLanguageFR'
- onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/>
- <JMenuItem id='menuFileLanguageUK'
- onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/>
- </JMenu>
- <JSeparator/>
- <JMenuItem id='menuFileFullscreen'
- onActionPerformed="getHandler().changeScreen(this, true)"/>
- <JMenuItem id='menuFileNormalscreen'
- onActionPerformed="getHandler().changeScreen(this, false)"/>
- <JSeparator/>
- <JMenuItem id='menuFileExit'
- onActionPerformed="getHandler().close(this)"/>
- </JMenu>
-
- <JMenu id='menuHelp'>
- <JMenuItem id='menuHelpHelp'
- onActionPerformed="getHandler().showHelp(this, null)"/>
- <JMenuItem id='menuHelpSite'
- onActionPerformed="getHandler().gotoSite(this)"/>
- <JMenuItem id='menuHelpAbout'
- onActionPerformed="getHandler().showAbout(this)"/>
- </JMenu>
-
- </JMenuBar>
-
- <JSplitPane id='splitPane'>
- <JScrollPane border='{null}'>
- <JTree id='navigation'
- model='{getTreeHelper().createTreeModel(this)}'
- selectionModel="{getTreeHelper().createTreeHandler(this)}"
- cellRenderer='{new NavigationTreeCellRenderer(this, 200)}'>
- </JTree>
- </JScrollPane>
-
- <JPanel id='content'/>
-
- </JSplitPane>
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<JFrame id='mainFrame' width='1024' height='800'
+ decorator='help'
+ onWindowClosing='getHandler().close(mainFrame)'>
+
+ <style source='DemoUI.css'/>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.tree.*;
+import java.util.Locale;
+
+public DemoConfig getConfig() {
+ return getContextValue(DemoConfig.class);
+}
+
+protected DemoUIHandler getHandler() {
+ return getContextValue(DemoUIHandler.class);
+}
+
+protected DemoTreeHelper getTreeHelper() {
+ return getContextValue(DemoTreeHelper.class);
+}
+
+public boolean acceptLocale(Locale l, String expected) {
+ return l !=null && l.toString().equals(expected);
+}
+
+private void $afterCompleteSetup() {
+ // share the tree
+ getTreeHelper().setTree(this, navigation);
+ // auto-expand node when selected
+ SwingUtil.addExpandOnClickListener(navigation);
+
+}
+
+]]>
+ </script>
+
+ <JMenuBar id='menu'>
+
+ <JMenu id='menuFile'>
+ <JMenuItem id='menuFileConfiguration'
+ onActionPerformed="getHandler().showConfig(this)"/>
+ <JMenu id='menuFileLanguage'>
+ <JMenuItem id='menuFileLanguageFR'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/>
+ <JMenuItem id='menuFileLanguageUK'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/>
+ </JMenu>
+ <JSeparator/>
+ <JMenuItem id='menuFileFullscreen'
+ onActionPerformed="getHandler().changeScreen(this, true)"/>
+ <JMenuItem id='menuFileNormalscreen'
+ onActionPerformed="getHandler().changeScreen(this, false)"/>
+ <JSeparator/>
+ <JMenuItem id='menuFileExit'
+ onActionPerformed="getHandler().close(this)"/>
+ </JMenu>
+
+ <JMenu id='menuHelp'>
+ <JMenuItem id='menuHelpHelp'
+ onActionPerformed="getHandler().showHelp(this, null)"/>
+ <JMenuItem id='menuHelpSite'
+ onActionPerformed="getHandler().gotoSite(this)"/>
+ <JMenuItem id='menuHelpAbout'
+ onActionPerformed="getHandler().showAbout(this)"/>
+ </JMenu>
+
+ </JMenuBar>
+
+ <JPanel id='mainPane' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane' constraints='BorderLayout.CENTER'>
+ <JScrollPane id='navigationPane'>
+ <JTree id='navigation'
+ model='{getTreeHelper().createTreeModel(this)}'
+ selectionModel="{getTreeHelper().createTreeHandler(this)}">
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this)}'>-->
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this,185)}'>-->
+ </JTree>
+ </JScrollPane>
+
+ <JPanel id='content'/>
+
+ </JSplitPane>
+
+ <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/>
+
+ </JPanel>
</JFrame>
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -23,7 +23,7 @@
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXInitialContext;
-import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import jaxx.runtime.swing.tree.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
@@ -102,8 +102,6 @@
@Override
public void run() {
-// // use best dimensions
-// ui.getSplitPane().resetToPreferredSizes();
String path;
if (node == null) {
@@ -111,23 +109,25 @@
path = "$root/jaxxdemo.tree.component.swing";
} else {
// take selected node
- path = node.getContextPath();
+ path = node.getFullPath();
}
+ log.info("node to re select " + path);
// select node
- ui.getTreeHelper().selectNode(ui, ui.getNavigation(), path);
-//
-// // show ui
-// ui.setVisible(true);
+ ui.getTreeHelper().selectNode(ui, path);
+
+ // use best dimensions
+ ui.getSplitPane().resetToPreferredSizes();
}
});
+
+ // show ui after all (in another invocation, tu avoid layout adjustement
+ // to be seen).
+
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- // use best dimensions
- ui.getSplitPane().resetToPreferredSizes();
-
// show ui
ui.setVisible(true);
}
@@ -154,7 +154,7 @@
node = ui.getTreeHelper().getSelectedNode(ui);
if (node != null) {
- log.info("selected node " + node.getContextPath());
+ log.info("selected node " + node.getFullPath());
}
ErrorDialogUI.init(null);
@@ -284,14 +284,20 @@
public void showAbout(DemoUI ui) {
+ DemoConfig config = ui.getConfig();
+
+ String iconPath = config.getOption("application.icon.path");
+ String licensePath = config.getOption("application.license.path");
+ String thirdPartyPath = config.getOption("application.third-party.path");
+
AboutPanel about = new AboutPanel();
-
about.setTitle(_("jaxxdemo.title.about"));
- about.setIconPath("/icons/jaxx.png");
about.setAboutText(_("jaxxdemo.about.message"));
about.setBottomText(ui.getConfig().getCopyrightText());
- about.setLicenseFile("META-INF/jaxx-example-LICENSE.txt");
- about.setThirdpartyFile("META-INF/jaxx-example-THIRD-PARTY.txt");
+ about.setIconPath(iconPath);
+ about.setLicenseFile(licensePath);
+ about.setThirdpartyFile(thirdPartyPath);
+ about.buildTopPanel();
about.init();
about.showInDialog(ui, true);
}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<jaxx.runtime.swing.BlockingLayerUI id='layerUI'
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<JPanel id='demoPanel' layout='{new BorderLayout()}'>
<JPanel layout='{new GridLayout(0,1)}' constraints='BorderLayout.CENTER'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<Table id='demoPanel' fill='both'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<String id='string' javaBean='null'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style>
JButton.fancy {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
public String getText(boolean bold, boolean italic, boolean underline) {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<JMenuItemDemo>
<style>
.form {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,22 +1,65 @@
-
-<jaxx.demo.DemoPanel>
- <Table id='demoPanel'>
- <row>
- <cell>
- <JLabel text='Button label:'/>
- </cell>
-
- <cell>
- <JComboBox id='comboBox' editable='true'>
- <item value='OK' selected='true'/>
- <item value='Cancel'/>
- <item value='Help'/>
- </JComboBox>
- </cell>
-
- <cell>
- <JButton text='{comboBox.getSelectedItem()}'/>
- </cell>
- </row>
- </Table>
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+
+private void $afterCompleteSetup() {
+ jaxxComboBox.setSelectedIndex(0);
+}
+]]>
+ </script>
+ <Table id='demoPanel'>
+ <row>
+ <cell>
+ <JLabel text='Button label:'/>
+ </cell>
+
+ <cell>
+ <JAXXComboBox id='jaxxComboBox' editable='true'>
+ <item value='{_("OK")}' selected='true'/>
+ <item value='{_("Cancel")}'/>
+ <item value='{_("Help")}'/>
+ </JAXXComboBox>
+ </cell>
+
+ <cell>
+ <JButton text='{jaxxComboBox.getSelectedItem()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Button label:'/>
+ </cell>
+
+ <cell>
+ <JComboBox id='comboBox'
+ editable='true'
+ model='{new DefaultComboBoxModel(new Object[]{n_("OK"),n_("Cancel"),n_("Help")})}'/>
+ </cell>
+
+ <cell>
+ <JButton text='{comboBox.getSelectedItem()}'/>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script>
String username;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<Table id='demoPanel'>
<row>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script>
void $afterCompleteSetup(){}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<HBox>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script><![CDATA[
import javax.swing.Timer;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<VBox>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<JMenuItemDemo>
<JMenuBar id='menuBar'>
<JMenu text='Font size'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<VBox>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<JLabel text='Spacing:' displayedMnemonic='S' labelFor='{spinner}'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<JPanel id='demoPanel' layout='{new BorderLayout()}'>
<JSplitPane>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<Table id='demoPanel' anchor='northwest'>
<row>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<JPanel id='demoPanel'>
<Table>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
<JToggleButton text='1' id='one'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<!-- a full java bean property of the class -->
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<BaseBeanDataBinding>
<Boolean id='editing3' javaBean='true'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source="Validation.css"/>
@@ -3,4 +23,6 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer;
+
void $afterCompleteSetup() {
}
@@ -310,7 +332,7 @@
width='500'>
<JScrollPane>
<JList id='errorList' model='{errors}'
- cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
+ cellRenderer='{new SwingValidatorMessageListRenderer()}'/>
</JScrollPane>
</JPanel>
</cell>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source="Validation.css"/>
@@ -31,9 +51,11 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
import jaxx.runtime.SwingUtil;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
void $afterCompleteSetup() {
- jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
+ SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
}
@Override
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source='Calculator.css'/>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<script>int count;</script>
<JPanel id='demoPanel'>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,23 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##%*
+-->
<jaxx.demo.DemoPanel>
<style source="LabelStyle.css"/>
<script><![CDATA[
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -47,6 +47,7 @@
Green=
Green\:=
Greet=
+Help=
I18n\ editor\ with\ no\ icon\ \:=
I18n\ editor\ with\ no\ text\ \:=
I18n\ editor\:=
@@ -111,7 +112,7 @@
form2.ratio=Form 2 Ratio
form2.text=Form 2 Text
form2.text2=Form 2 Text 2
-jaxxdemo.about.message=<h3>JAXX Demo</h3>Demo du framework JAXX <hr/><p>Ce projet a \u00E9t\u00E9 r\u00E9alis\u00E9 par la soci\u00E9t\u00E9 <a href\="http\://codelutin.com">Codelutin</a> en 2009.</p><br/><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-example">site du projet</a>.
+jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>.
jaxxdemo.action.about=About...
jaxxdemo.action.about.tip=About JAXXDemo...
jaxxdemo.action.configuration=Preferences
@@ -120,7 +121,7 @@
jaxxdemo.action.exit.tip=Quit JAXXDemo
jaxxdemo.action.fullscreen=Full screen
jaxxdemo.action.fullscreen.tip=Change to full screen mode
-jaxxdemo.action.help=Help
+jaxxdemo.action.help=
jaxxdemo.action.help.tip=Display help
jaxxdemo.action.locale.fr=French
jaxxdemo.action.locale.fr.tip=Change to french language
@@ -142,7 +143,7 @@
jaxxdemo.init.ui.done=UI initialized.
jaxxdemo.menu.file=File
jaxxdemo.menu.file.locale=Languages
-jaxxdemo.menu.help=Help
+jaxxdemo.menu.help=
jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded.
jaxxdemo.message.goto.site=Go to JAXXDemo Web site
jaxxdemo.title.about=About JAXXDemo...
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -20,7 +20,7 @@
Blue=Bleu
Blue\:=bleu \:
Bold=En gras
-Button\ label\:=Libell\u00E9 du label
+Button\ label\:=Libell\u00E9 de l'action
C=C
CE=CE
Cancel=Annuler
@@ -47,6 +47,7 @@
Green=Vert
Green\:=Vert \:
Greet=
+Help=
I18n\ editor\ with\ no\ icon\ \:=Editeur I18n sans icone \:
I18n\ editor\ with\ no\ text\ \:=Editeur I18n sans texte \:
I18n\ editor\:=Editeur I18n
@@ -111,7 +112,7 @@
form2.ratio=Form2 \: ratio
form2.text=Form2 \: text
form2.text2=Form2 \: text2
-jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/kaxx/jaxx-demo">site du projet</a>.
+jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>.
jaxxdemo.action.about=A propos
jaxxdemo.action.about.tip=A propos de JAXX Demo...
jaxxdemo.action.configuration=Configuration
@@ -159,7 +160,7 @@
jaxxdemo.tree.feature=Fonctionnalit\u00E9s
jaxxdemo.tree.features.databinding=Data binding
jaxxdemo.tree.features.validation=Validation
-jaxxdemo.tree.fun=Contestes
+jaxxdemo.tree.fun=Fun
jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
movies=Films
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -6,5 +6,7 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
log4j.logger.jaxx.demo=INFO
-#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeHandler=DEBUG
+#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeCellRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeNodeRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeModel=DEBUG
log4j.logger.org.nuiton=WARN
Property changes on: branches/jaxx-2.X/jaxx-runtime
___________________________________________________________________
Added: svn:ignore
+ target
*.log
*.iml
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,11 +10,11 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<dependencies>
@@ -62,8 +62,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx runtime api</description>
+ <name>JAXX Runtime</name>
+ <description>JAXX Runtime api</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -81,6 +81,14 @@
<goal>parserJava</goal>
<goal>gen</goal>
</goals>
+ <configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <basedir>src/main/java/jaxx/runtime/validator</basedir>
+ </entry>
+ </entries>
+ </configuration>
</execution>
</executions>
</plugin>
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.beaninfos;
+
+import jaxx.runtime.swing.HBox;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class HBoxBeanInfo extends SimpleBeanInfo {
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", HBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", HBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", HBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", HBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.beaninfos;
+
+import jaxx.runtime.swing.VBox;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class VBoxBeanInfo extends SimpleBeanInfo {
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", VBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", VBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", VBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", VBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ }
+ catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,176 +0,0 @@
-package jaxx.runtime;
-
-import jaxx.runtime.*;
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import jaxx.runtime.validator.*;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The helper class for validation module.
- *
- * @author chemit
- */
-public class BeanValidatorUtil {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
- /**
- * a shared value stack to allow external operations on it (for example
- * add some datas in stack to be usedby validators
- */
- static private ValueStack sharedValueStack;
-
- public static synchronized ValueStack getSharedValueStack() {
- if (sharedValueStack == null) {
-
- // init context
- ConfigurationManager confManager = new ConfigurationManager();
- Configuration conf = confManager.getConfiguration();
-
- sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
- if (log.isDebugEnabled()) {
- log.debug("init shared value stack " + sharedValueStack);
- }
- }
- return sharedValueStack;
- }
-
- protected BeanValidatorUtil() {
- // no instance
- }
-
- /**
- * Convinient method to attach a bean to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param bean the bean to attach in validators (can be null)
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
- if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
- // touch validator, only if fits the bean type (or bean is null)
- beanValidator.setBean(bean);
- }
- }
- }
-
- /**
- * Convinient method to set the changed property to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param newValue the new value to set in changed validator property
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
- beanValidator.setChanged(newValue);
- }
- }
-
- /**
- * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
- *
- * @param validator validator to be involved
- * @param fieldName the name of the bean property
- * @param value the actual value to convert
- * @param valueClass the type of the conversion
- */
- public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
-
- Object result = validator.convert(fieldName, value, valueClass);
- if (result != null) {
- try {
- BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
-
- for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
- if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
-
- descriptor.getWriteMethod().invoke(validator.getBean(), result);
- break;
- }
- }
- } catch (IntrospectionException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (InvocationTargetException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (IllegalAccessException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- }
- } else {
- //fixme : conversion failed, we should be able to notify ui that values has changed ?
- // otherwise, bean value has not changed,...
- }
- }
-
- public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
- try {
- // check that the bean is listenable, otherwise, can't use
- // the validator on it
- BeanInfo infos = Introspector.getBeanInfo(beanClass);
- EventSetDescriptor[] events = infos.getEventSetDescriptors();
- for (EventSetDescriptor event : events) {
- if ("propertyChange".equals(event.getName())) {
-
- if (event.getAddListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
- }
- if (event.getRemoveListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
- }
- return event;
- }
- }
-
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
- } catch (IntrospectionException ex) {
- throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
- }
- }
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DataContext.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -150,12 +150,12 @@
return result;
}
- public void setContextValue(DataContextEntry entry, Object value, String key) {
+ public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
String contextKey = getKey(entry, key);
delegate.setContextValue(value, contextKey);
}
- public void removeContextValue(DataContextEntry entry, Object value, String key) {
+ public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
String contextKey = getKey(entry, key);
delegate.removeContextValue(value.getClass(), contextKey);
}
@@ -246,7 +246,7 @@
pcs.firePropertyChange(name, oldValue, newValue);
}
- protected String getKey(DataContextEntry entry, String key) {
+ protected String getKey(DataContextEntry<?> entry, String key) {
String result = null;
if (key != null) {
result = entry.hashCode() + "#" + key;
@@ -259,7 +259,7 @@
// suppression des ecouteurs
- for (PropertyChangeListener l : getPropertyChangeListeners()) {
+ for (PropertyChangeListener l : getPropertyChangeListeners()) {
removePropertyChangeListener(l);
}
}
@@ -272,14 +272,14 @@
private final int level;
private final DataContextEntry<?> previous;
- private final DataContextEntry[] parents;
+ private final DataContextEntry<?>[] parents;
private Class<E> klass;
public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
this.previous = previous;
this.level = previous.level + 1;
this.klass = klass;
- this.parents = new DataContextEntry[level];
+ this.parents = new DataContextEntry<?>[level];
int i = level;
while (i > 0) {
parents[--i] = previous;
@@ -291,7 +291,7 @@
this.level = 0;
this.klass = klass;
this.previous = null;
- this.parents = new DataContextEntry[0];
+ this.parents = new DataContextEntry<?>[0];
}
public Class<E> getKlass() {
@@ -302,7 +302,7 @@
return level;
}
- public DataContextEntry[] getParents() {
+ public DataContextEntry<?>[] getParents() {
return parents;
}
@@ -321,7 +321,7 @@
@Override
public Iterator<DataContextEntry<?>> iterator() {
int length = parents.length;
- DataContextEntry[] t = new DataContextEntry[length + 1];
+ DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1];
System.arraycopy(parents, 0, t, 0, length);
t[length] = this;
return new DataContextEntryIterator(t, true);
@@ -335,31 +335,31 @@
public static interface UpdateDataContext<D extends DataContext> {
- void onRemovingData(D context, DataContextEntry<?> entry);
+ void onRemovingData(D context, DataContextEntry<D> entry);
- void onAddingData(D context, DataContextEntry entry, String path);
+ void onAddingData(D context, DataContextEntry<D> entry, String path);
}
public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> {
- protected final DataContextEntry[] datas;
+ protected final DataContextEntry<?>[] datas;
protected final boolean reverse;
protected final int level;
protected int index;
- public DataContextEntryIterator(DataContextEntry[] datas) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas) {
this(datas, false, -1);
}
- public DataContextEntryIterator(DataContextEntry[] datas, int level) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
this(datas, false, level);
}
- public DataContextEntryIterator(DataContextEntry[] datas, boolean reverse) {
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
this(datas, reverse, -1);
}
- DataContextEntryIterator(DataContextEntry[] datas, boolean reverse, int level) {
+ DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
this.datas = datas;
this.reverse = reverse;
if (reverse) {
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/Decorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Decorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,36 +0,0 @@
-package jaxx.runtime;
-
-/**
- * A simple contract to define a String decorator on any java objet.
- *
- * @param <O> the type of decorated object
- * @author chemit
- */
-public abstract class Decorator<O> implements java.io.Serializable {
-
- protected final Class<O> internalClass;
- private static final long serialVersionUID = -1L;
-
- /**
- * @param internalClass the class of objects to be decorated.
- * @throws NullPointerException if internalClass parameter is null
- */
- public Decorator(Class<O> internalClass) throws NullPointerException {
- if (internalClass == null) {
- throw new NullPointerException("internalClass can not be null.");
- }
- this.internalClass = internalClass;
- }
-
- /**
- * @param bean the bean to decorate
- * @return the string value of the given bean
- */
- public abstract String toString(Object bean);
-
-
- public final Class<O> getInternalClass() {
- return internalClass;
- }
-
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DecoratorUtils.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DecoratorUtils.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,111 +0,0 @@
-package jaxx.runtime;
-
-import java.util.List;
-
-/**
- *
- * Some usefull methods on {@link Decorator} to store and obtain decorators.
- *
- * Use the method {@link #registerDecorator(String, Decorator)} to register a new
- * decorator.
- *
- * Use the method {@link #getDecorator(String)} to obtain a registred
- * decorator based on his registred name.
- *
- * Use the method {@link #getDecorator(Class, tring)} to obtain a registred
- * decorator based on the type of decorator and the registred name.
- *
- * @author tony
- * @since 1.3
- */
-public class DecoratorUtils {
-
- protected static List<DecoratorContext<?>> cache;
-
- public static <T> void registerDecorator(String context, Decorator<T> decorator) {
- DecoratorContext<T> result = getDecoratorContext(decorator.getInternalClass(), context);
-
- if (result != null) {
- throw new IllegalArgumentException("there is an already register decorator " + result);
- }
-
- if (cache == null) {
- cache = new java.util.ArrayList<DecoratorContext<?>>();
- }
- cache.add(new DecoratorContext<T>(context, decorator));
- }
-
- public static <T> Decorator<T> getDecorator(String context) {
- Decorator<T> result = getDecorator(null, context);
- return result;
- }
-
- public static <T> Decorator<T> getDecorator(Class<T> type, String context) {
- DecoratorContext<T> decoratorContext = getDecoratorContext(type, context);
- Decorator<T> result = decoratorContext == null ? null : decoratorContext.getDecorator();
- return result;
- }
-
- public static void clear() {
- if (cache != null) {
- cache.clear();
- }
- }
-
- @SuppressWarnings({"unchecked"})
- protected static <T> DecoratorContext<T> getDecoratorContext(Class<T> type, String context) {
- DecoratorContext<T> result = null;
- if (cache != null) {
- for (DecoratorContext<?> d : cache) {
- if (type == null) {
- if (d.accept(context)) {
- result = (DecoratorContext<T>) d;
- break;
- }
- continue;
- }
- if (d.accept(type, context)) {
- result = (DecoratorContext<T>) d;
- break;
- }
- }
- }
- return result;
- }
-
- public static class DecoratorContext<T> {
-
- final String context;
- final Decorator<T> decorator;
-
- public DecoratorContext(String context, Decorator<T> decorator) {
- this.context = context;
- this.decorator = decorator;
- }
-
- public String getContext() {
- return context;
- }
-
- public Decorator<T> getDecorator() {
- return decorator;
- }
-
- public Class<T> getType() {
- return decorator.getInternalClass();
- }
-
- public boolean accept(Class<?> type, String context) {
- return getType().isAssignableFrom(type) && accept(context);
- }
-
- public boolean accept(String context) {
- return ((this.context == null && context == null) || (this.context != null && this.context.equals(context)));
- }
-
- @Override
- public String toString() {
- return super.toString() + "<type: " + getType().getName() + ", context :" + context + ">";
- }
- }
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -78,11 +78,11 @@
/**
* Map of forwarded classes (key) to classes (values).
*/
- protected Map<Class, Class> forwards;
+ protected Map<Class<?>, Class<?>> forwards;
public DefaultApplicationContext() {
super();
- forwards = new HashMap<Class, Class>();
+ forwards = new HashMap<Class<?>, Class<?>>();
pcs = new PropertyChangeSupport(this);
}
@@ -165,10 +165,10 @@
@Override
public <T> void removeContextValue(Class<T> klazz, String name) {
- Entry<Class, Class> entry;
+ Entry<Class<?>, Class<?>> entry;
if (name == null && forwards.containsValue(klazz)) {
// remove forward
- Iterator<Entry<Class, Class>> itr = forwards.entrySet().iterator();
+ Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
while (itr.hasNext()) {
entry = itr.next();
if (entry.getValue().equals(klazz)) {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -29,6 +29,7 @@
* <p/>
* If a previous entry exists in context (unamed and same class), it will be removed.
*
+ * @param <T> type of data to set in context
* @param o the value to push in context
*/
public <T> void setContextValue(T o);
@@ -38,6 +39,7 @@
* <p/>
* If a previous entry exists in context (same name and class), it will be removed.
*
+ * @param <T> type of data to set in context
* @param o the value to push in context
* @param name the name of the new entry
*/
@@ -46,6 +48,7 @@
/**
* Remove from context the value with the given klazz as an unamed entry
*
+ * @param <T> type of data to remove from context
* @param klazz the klazz entry
*/
public <T> void removeContextValue(Class<T> klazz);
@@ -53,6 +56,7 @@
/**
* Remove from context the value with the given klazz as an unamed (if name is null) or named entry
*
+ * @param <T> type of data to remove from context
* @param klazz the klazz entry
* @param name extra name of the entry
*/
@@ -66,6 +70,7 @@
* <p/>
* <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
*
+ * @param <T> type of data to obtain from context
* @param clazz the class of unamed entry to seek in context
* @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
*/
@@ -74,6 +79,7 @@
/**
* Seek for a named entry in the context
*
+ * @param <T> type of data to obtain from context
* @param clazz the class of named entry to seek in context
* @param name the name of the entry to seek in context
* @return the value of the named entry for the given class, or <code>null</code> if no such entry.
@@ -83,6 +89,7 @@
/**
* Return parent's container corresponding to the Class clazz
*
+ * @param <O> type of container to obtain from context
* @param clazz clazz desired
* @return parent's container
*/
@@ -91,6 +98,7 @@
/**
* Return parent's container corresponding to the Class clazz
*
+ * @param <O> type of container to obtain from context
* @param top the top container
* @param clazz desired
* @return parent's container
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JXPathDecorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,278 +0,0 @@
-package jaxx.runtime;
-
-import org.apache.commons.jxpath.JXPathContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * JXPath decorator based on {@link String#format(String, Object[])} method.
- * <p/>
- * To use it, give to him a expression where all jxpath to apply on bean are boxed in <code>${}</code>.
- * <p/>
- * After the jxpath token you must specifiy the formatter to apply of the jxpath token.
- * <p/>
- * For example :
- * <pre>
- * Decorator<Object> d = JXPathDecorator.newDecorator(JXPathDecorator.class,"expr = ${expressions}$s");
- * assert "expr = %1$s" == d.getExpression();
- * assert 1 == d.getNbToken();
- * assert java.util.Arrays.asList("expression") == d.getTokens();
- * assert "expr = %1$s" == d.toString(d);
- * </pre>
- *
- * @param <O> type of data
- * @author chemit
- * @see Decorator
- */
-public class JXPathDecorator<O> extends Decorator<O> {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(JXPathDecorator.class);
- private static final long serialVersionUID = 1L;
-
- /**
- * Factory method to instanciate a new {@link JXPathDecorator} for the given class {@link O} and expression.
- *
- * @param internalClass the class of the objects decorated by the new decorator
- * @param expression the expression to use to decorated objects
- * @param <O> the generic type of class to be decorated by the new decorator
- * @return the new instanciated decorator
- * @throws IllegalArgumentException if the expression is not valid, says:
- * <p/>
- * - a missing right brace was detected.
- * <p/>
- * - a ${ was found in a jxpath token.
- * @throws NullPointerException if internalClass parameter is null.
- */
- public static <O> JXPathDecorator<O> newDecorator(Class<O> internalClass, String expression)
- throws IllegalArgumentException, NullPointerException {
- return new JXPathDecorator<O>(internalClass, expression, true);
- }
-
- /**
- * 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 = 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();
- }
- }
- }
-
- public static class JXPathComparator<O> implements Comparator<O> {
-
- protected Map<O, Comparable<Comparable<?>>> valueCache;
- private final String expression;
-
- public JXPathComparator(String expression) {
- this.expression = expression;
- 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);
- return c1.compareTo(c2);
- }
-
- public void clear() {
- valueCache.clear();
- }
-
- public void init(JXPathDecorator<O> decorator, List<O> datas) {
- clear();
- for (O data : datas) {
- JXPathContext jxcontext = JXPathContext.newContext(data);
- Comparable<Comparable<?>> key = decorator.getTokenValue(jxcontext, expression);
- valueCache.put(data, key);
- }
- }
- }
-
- public static class Context<O> implements java.io.Serializable {
-
- /**
- * expression to format using {@link String#format(String, Object[])}, all variables are compute
- * using using the jxpath tokens.
- */
- protected String expression;
- /** list of jxpath tokens to apply on expression */
- protected String[] tokens;
- protected transient Comparator<O> comparator;
- private static final long serialVersionUID = 1L;
-
- public Context(String expression, String[] tokens) {
- this.expression = expression;
- this.tokens = tokens;
- }
-
- public String getFirstProperty() {
- return tokens[0];
- }
-
- public Comparator<O> getComparator(int pos) {
- if (comparator == null) {
- comparator = new JXPathComparator<O>(tokens[pos]);
- }
- return comparator;
- }
-
- public void setComparator(Comparator<O> comparator) {
- this.comparator = comparator;
- }
-
- @Override
- public String toString() {
- return "<expression:" + expression + ", tokens:" + Arrays.toString(tokens) + ">";
- }
- }
- /** the computed context of the decorator */
- protected Context<O> context;
- /** nb jxpath tokens to compute */
- protected int nbToken;
- /** the initial expression used to compute the decorator context. */
- protected String initialExpression;
-
- @Override
- public String toString(Object bean) {
- if (bean == null) {
- return null;
- }
- JXPathContext jxcontext = JXPathContext.newContext(bean);
- Object[] args = new Object[nbToken];
-
- for (int i = 0; i < nbToken; i++) {
- try {
- args[i] = getTokenValue(jxcontext, context.tokens[i]);
- } catch (Exception e) {
- log.error("can not obtain token " + context.tokens[i] + "on object " + bean + " for reason " + e.getMessage(), e);
-
- }
- }
-
- return String.format(context.expression, args);
- }
-
- @SuppressWarnings({"unchecked"})
- protected Comparable<Comparable<?>> getTokenValue(JXPathContext jxcontext, String token) {
- // assume all values are comparable
- return (Comparable<Comparable<?>>) jxcontext.getValue(token);
- }
-
- public String getProperty(int pos) {
- return getTokens()[pos];
- }
-
- public String getExpression() {
- return context.expression;
- }
-
- public String[] getTokens() {
- return context.tokens;
- }
-
- public int getNbToken() {
- return nbToken;
- }
-
- public String getInitialExpression() {
- return initialExpression;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<" + context + ">";
- }
-
- public void setContext(Context<O> context) {
- this.context = context;
- this.nbToken = context.tokens.length;
- // always reset comparator
- //this.context.comparator = null;
- if (log.isDebugEnabled()) {
- log.debug(context);
- }
- }
-
- public JXPathDecorator(Class<O> internalClass, String expression, boolean creatContext) throws IllegalArgumentException, NullPointerException {
- super(internalClass);
- this.initialExpression = expression;
- if (creatContext) {
- setContext(JXPathDecorator.<O>createInitialContext(expression));
- if (log.isDebugEnabled()) {
- log.debug(expression + " --> " + this.context);
- }
- }
- }
-
- @SuppressWarnings({"unchecked"})
- protected Comparator<O> getComparator(int pos) {
- ensureTokenIndex(this, pos);
- return context.getComparator(pos);
- }
-
- public static <O> Context<O> createInitialContext(String expression) {
- List<String> lTokens = new ArrayList<String>();
- StringBuilder buffer = new StringBuilder();
- int size = expression.length();
- int end = -1;
- int start;
- while ((start = expression.indexOf("${", end + 1)) > -1) {
- if (start > end + 1) {
- // prefix of next jxpath token
- buffer.append(expression.substring(end + 1, start));
- }
- // seek end of jxpath
- end = expression.indexOf("}", start + 1);
- if (end == -1) {
- throw new IllegalArgumentException("could not find the rigth brace starting at car " + start + " : " + expression.substring(start + 2));
- }
- String jxpath = expression.substring(start + 2, end);
- // not allowed ${ inside a jxpath token
- if (jxpath.indexOf("${") > -1) {
- throw new IllegalArgumentException("could not find a ${ inside a jxpath expression at car " + (start + 2) + " : " + jxpath);
- }
- // save the jxpath token
- lTokens.add(jxpath);
- // replace jxpath token in expresion with a string format variable
- buffer.append("%").append(lTokens.size());
- }
- if (size > (end + 1)) {
- // suffix after end jxpath (or all expression if no jxpath)
- buffer.append(expression.substring(end + 1));
- }
- return new Context<O>(buffer.toString(), lTokens.toArray(new String[lTokens.size()]));
- }
-
- 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 + "]");
- }
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,23 @@
+package jaxx.runtime;
+
+import java.awt.Component;
+import jaxx.runtime.swing.JaxxHelpBroker;
+
+/**
+ *
+ * Contract to be added on JAXXObject wihch wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JaxxHelpBroker
+ */
+public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/MultiJXPathDecorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/MultiJXPathDecorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,129 +0,0 @@
-package jaxx.runtime;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * TODO
- *
- * @param <O> type of decorated objects
- * @author chemit
- * @see jaxx.runtime.Decorator
- */
-public class MultiJXPathDecorator<O> extends JXPathDecorator<O> {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(MultiJXPathDecorator.class);
-
- private static final long serialVersionUID = 1L;
-
- public static <O> MultiJXPathDecorator<O> newDecorator(Class<O> internalClass,
- String expression,
- String separator)
- throws IllegalArgumentException, NullPointerException {
-
- return newDecorator(internalClass, expression, separator, separator);
- }
-
- public static <O> MultiJXPathDecorator<O> newDecorator(Class<O> internalClass,
- String expression,
- String separator,
- String separatorReplacement)
- throws IllegalArgumentException, NullPointerException {
-
- Context<O>[] contexts = createInitialContexts(expression, separator, separatorReplacement);
-
- return new MultiJXPathDecorator<O>(internalClass, expression, separator, separatorReplacement, contexts);
- }
-
- protected Context<O>[] contexts;
- protected String separator;
- protected String separatorReplacement;
-
-
- public MultiJXPathDecorator(Class<O> internalClass, String expression,
- String separator, String separatorReplacement,
- Context<O>[] contexts) throws IllegalArgumentException, NullPointerException {
- super(internalClass, expression, false);
- this.separator = separator;
- this.separatorReplacement = separatorReplacement;
- this.contexts = contexts;
-
- setContextIndex(0);
-
- if (log.isDebugEnabled()) {
- log.debug(expression + " --> " + this.context);
- }
- }
-
- public void setContextIndex(int index) {
- ensureContextIndex(this, index);
- setContext(contexts[index]);
- }
-
- public int getNbContext() {
- return contexts.length;
- }
-
- public String getSeparator() {
- return separator;
- }
-
- public String getSeparatorReplacement() {
- return separatorReplacement;
- }
-
- @Override
- protected Comparator<O> getComparator(int pos) {
- ensureContextIndex(this, pos);
- Context<O> context1 = contexts[pos];
- return context1.getComparator(0);
- }
-
- public static <O> Context<O>[] createInitialContexts(String expression, String separator, String separatorReplacement) {
- int sep = expression.indexOf(separator);
- if (sep == -1) {
- Context<O>[] result = MultiJXPathDecorator.newInstance(1);
- result[0] = createInitialContext(expression);
- return result;
- }
-
- List<String> tokens = new ArrayList<String>();
- StringTokenizer stk = new StringTokenizer(expression, separator);
- while (stk.hasMoreTokens()) {
- tokens.add(stk.nextToken());
- }
-
- int nbTokens = tokens.size();
- Context<O>[] contexts = newInstance(nbTokens);
- for (int i = 0; i < nbTokens; i++) {
- StringBuilder buffer = new StringBuilder(expression.length());
- for (int j = 0; j < nbTokens; j++) {
- int index = (i + j) % nbTokens;
- String str = tokens.get(index);
- //todo replace %index with %j
- buffer.append(separatorReplacement).append(str);
- }
- contexts[i] = createInitialContext(buffer.substring(separatorReplacement.length()));
- }
- return contexts;
- }
-
- protected static void ensureContextIndex(MultiJXPathDecorator<?> decorator, int pos) {
- if (pos < -1 || pos > decorator.contexts.length) {
- throw new ArrayIndexOutOfBoundsException("context index " + pos + " is out of bound, can be inside [" + 0 + "," + decorator.contexts.length + "]");
- }
- }
-
- @SuppressWarnings("unchecked")
- protected static <O> Context<O>[] newInstance(int size) {
- // fixme how to instanciate a typed array with no checking warning ?
- return new Context[size];
- }
-
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/PropertyDecorator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/PropertyDecorator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,94 +0,0 @@
-package jaxx.runtime;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-
-/**
- * Simple property decorator based on {@link String#format(String, Object[])} method.
- * <p/>
- * To use it, give him a class and the property name to render.
- * <p/>
- * For example :
- * <pre>
- * Decorator<Object> d = PropertyDecorator.newDecorator(PropertyDecorator.class,"expressions");
- * </pre>
- *
- * @param <O> type of decorated objects
- * @author chemit
- * @see Decorator
- */
-public class PropertyDecorator<O> extends Decorator<O> {
-
- private static final long serialVersionUID = 1L;
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(PropertyDecorator.class);
-
- /**
- * Factory method to instanciate a new {@link jaxx.runtime.PropertyDecorator} for the given class {@link O} and a
- * readable property name.
- *
- * @param internalClass the class of the objects decorated by the new decorator
- * @param property the property
- * @param <O> the generic type of class to be decorated by the new decorator
- * @return the new instanciated decorator
- * @throws IllegalArgumentException if the expression is not valid, says:
- * <p/>
- * - a missing right brace was detected.
- * <p/>
- * - a ${ was found in a jxpath token.
- * @throws NullPointerException if internalClass parameter is null.
- */
- public static <O> PropertyDecorator<O> newDecorator(Class<O> internalClass, String property)
- throws IllegalArgumentException, NullPointerException {
- return new PropertyDecorator<O>(internalClass, property);
- }
-
- protected String property;
-
- protected transient Method m;
-
- @Override
- public String toString(Object bean) {
- try {
- return getM().invoke(bean) + "";
- } catch (Exception e) {
- log.error("could not convert for reason : " + e, e);
- return "";
- }
- }
-
- public String getProperty() {
- return property;
- }
-
- protected PropertyDecorator(Class<O> internalClass, String property) throws NullPointerException {
- super(internalClass);
- if (property == null) {
- throw new NullPointerException("property can not be null.");
- }
- this.property = property;
- // init method
- getM();
- }
-
-
- protected Method getM() {
- if (m == null) {
- for (PropertyDescriptor propertyDescriptor : PropertyUtils.getPropertyDescriptors(internalClass)) {
- if (propertyDescriptor.getName().equals(property)) {
- this.m = propertyDescriptor.getReadMethod();
- break;
- }
- }
- if (m == null) {
- throw new IllegalArgumentException("could not find the property " + property + " in " + internalClass);
- }
- }
- return m;
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,762 @@
+package jaxx.runtime;
+
+import jaxx.runtime.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Desktop;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Rectangle;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.JTextComponent;
+import java.lang.reflect.Field;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JLayeredPane;
+import javax.swing.JRootPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTree;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.swing.BooleanCellRenderer;
+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;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ * The runtime swing util class with some nice stuff.
+ *
+ * Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class SwingUtil extends Util {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingUtil.class);
+ private static Field numReaders;
+ private static Field notifyingListeners;
+ public static final String ICON_PREFIX = "icon.";
+ public static final String COLOR_PREFIX = "color.";
+
+ public static Dimension newMinDimension() {
+ return new Dimension(0, 0);
+ }
+
+ public static Dimension newMaxXDimension() {
+ return new Dimension(Short.MAX_VALUE, 0);
+ }
+
+ public static Dimension newMaxYDimension() {
+ return new Dimension(0, Short.MAX_VALUE);
+ }
+
+ public static Dimension newMaxXYDimension() {
+ return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
+ }
+
+ public static void setText(final JTextComponent c, final String text) {
+ try {
+ // AbstractDocument deadlocks if we try to acquire a write lock while a read lock is held by the current thread
+ // If there are any readers, dispatch an invokeLater. This should only happen in the event of circular bindings.
+ // Similarly, circular bindings can result in an "Attempt to mutate in notification" error, which we deal with
+ // by checking for the 'notifyingListeners' property.
+ AbstractDocument document = (AbstractDocument) c.getDocument();
+ if (numReaders == null) {
+ numReaders = AbstractDocument.class.getDeclaredField("numReaders");
+ numReaders.setAccessible(true);
+ }
+ if (notifyingListeners == null) {
+ notifyingListeners = AbstractDocument.class.getDeclaredField("notifyingListeners");
+ notifyingListeners.setAccessible(true);
+ }
+
+ if (notifyingListeners.get(document).equals(Boolean.TRUE)) {
+ return;
+ }
+
+ if ((Integer) numReaders.get(document) > 0) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (!c.getText().equals(text)) {
+ c.setText(text);
+ }
+ }
+ });
+ return;
+ }
+
+ String oldText = c.getText();
+ if (oldText == null || !oldText.equals(text)) {
+ c.setText(text);
+ }
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ c.setText(text);
+ }
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param combo the combo to fill
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ */
+ public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) {
+ if (!(combo.getModel() instanceof DefaultComboBoxModel)) {
+ throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass());
+ }
+ DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
+ // evince the model
+ model.removeListDataListener(combo);
+ model.removeAllElements();
+ if (data != null) {
+ for (Object o : data) {
+ model.addElement(o);
+ }
+ }
+ // attach the model
+ model.addListDataListener(combo);
+ model.setSelectedItem(select);
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param combo the combo to fill
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ * @param firstNull add a first null element
+ */
+ public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) {
+ List<Item> items = new ArrayList<Item>();
+ if (firstNull) {
+ items.add(new Item("null", " ", null, false));
+ }
+ if (data != null) {
+ for (Object d : data) {
+ items.add(new Item(d.toString(), d.toString(), d, d.equals(select)));
+ }
+ }
+ combo.setItems(items);
+ }
+
+ public static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix) {
+ int width = 0;
+ if (font == null) {
+ font = table.getFont();
+ }
+// if (font == null) {
+// TableColumn column = table.getColumnModel().getColumn(columnIndex);
+// font = ((JComponent) column.getCellRenderer()).getFont();
+// }
+ FontMetrics fontMetrics = table.getFontMetrics(font);
+ for (int i = 0, rowCount = table.getRowCount(); i < rowCount; i++) {
+ String key = (String) table.getModel().getValueAt(i, 0);
+ int w = fontMetrics.stringWidth(key + suffix);
+ if (w > width) {
+ width = w;
+ }
+ }
+ return width;
+ }
+
+ public static void fixTableColumnWidth(JTable table, int columnIndex, int width) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setMaxWidth(width);
+ column.setMinWidth(width);
+ column.setWidth(width);
+ column.setPreferredWidth(width);
+ }
+
+ public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setCellEditor(editor);
+ }
+
+ public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setCellRenderer(editor);
+ }
+
+ public static void setI18nTableHeaderRenderer(JTable table, String... libelles) {
+ table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles));
+ }
+
+ public static TableCellRenderer newStringTableCellRenderer(final DefaultTableCellRenderer renderer, final int length, final boolean tooltip) {
+
+ return new DefaultTableCellRenderer() {
+
+ private static final long serialVersionUID = 1l;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ String val = renderer.getText();
+ String val2 = val;
+ if (val.length() > length) {
+ val2 = val.substring(0, length - 3) + "...";
+ }
+
+ JComponent comp = (JComponent) super.getTableCellRendererComponent(table, val2, isSelected, hasFocus, row, column);
+ if (tooltip) {
+ comp.setToolTipText(val);
+ }
+ return comp;
+ }
+ };
+ }
+
+ /**
+ * Box a component in a {@link org.jdesktop.jxlayer.JXLayer}.
+ *
+ * @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);
+ if (layer != null) {
+ return layer;
+ }
+ layer = new org.jdesktop.jxlayer.JXLayer<JComponent>();
+ layer.add(component);
+ return layer;
+ }
+
+ public static List<JComponent> getLayeredComponents(JAXXObject object) {
+ List<JComponent> result = new ArrayList<JComponent>();
+ for (Entry<String, Object> child : object.get$objectMap().entrySet()) {
+ if (child.getValue() == null) {
+ log.warn("find a null object in $objectMap " + child.getKey());
+ continue;
+ }
+ if (JComponent.class.isAssignableFrom(child.getValue().getClass())) {
+ JComponent comp = (JComponent) child.getValue();
+ if (isLayered(comp)) {
+ result.add(comp);
+ }
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static JXLayer<JComponent> getLayer(JComponent comp) {
+ if (!isLayered(comp)) {
+ return null;
+ }
+ return (JXLayer<JComponent>) comp.getParent();
+ }
+
+ public static boolean isLayered(JComponent comp) {
+ Container parent = comp.getParent();
+ return parent != null && parent instanceof JXLayer<?>;
+ }
+
+ /**
+ * recherche les composants portant le meme nom que les champs de la classe
+ * clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser
+ * dans un autre context (je pense par exemple a la generation jaxx).
+ * <p/>
+ * <p/>
+ * Si la recherche echoue pour quelque raison que se soit, aucune exception
+ * n'est leve, et la map retournee est tout simplement vide ou incomplete
+ *
+ * @param clazz la classe ou recherche les champs
+ * @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) {
+ Map<String, JComponent> result = new HashMap<String, JComponent>();
+ try {
+ // looking for all component with name set
+ Map<String, JComponent> allNamedComponent = new HashMap<String, JComponent>();
+ List<Container> todo = new LinkedList<Container>();
+ todo.add(container);
+ while (todo.size() > 0) {
+ for (ListIterator<Container> i = todo.listIterator(); i.hasNext();) {
+ Container parent = i.next();
+ i.remove();
+ for (Component c : parent.getComponents()) {
+ if (c instanceof Container) {
+ i.add((Container) c);
+ String name = c.getName();
+ if (c instanceof JComponent &&
+ name != null && !"".equals(name)) {
+ allNamedComponent.put(name, (JComponent) c);
+ }
+ }
+ }
+ }
+ }
+
+ // looking for all properties on class
+ BeanInfo info = Introspector.getBeanInfo(clazz);
+ PropertyDescriptor[] props = info.getPropertyDescriptors();
+
+ // find if one properties have same name that component
+ for (PropertyDescriptor prop : props) {
+ String name = prop.getName();
+ if (allNamedComponent.containsKey(name)) {
+ result.put(name, allNamedComponent.get(name));
+ }
+ }
+
+ } catch (IntrospectionException eee) {
+ log.warn("Can't introspect bean", eee);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Result: " + result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Centrer un component graphique au center d'un autre component.
+ *
+ * <b>Note:</b> si le parent est null, alors on ne fait rien.
+ *
+ * @param parent le component parent
+ * @param component le component à centrer
+ */
+ public static void center(Component parent, Component component) {
+ if (parent == null) {
+ return;
+ }
+ Rectangle r = parent.getBounds();
+ int x = r.x + (r.width - component.getSize().width) / 2;
+ int y = r.y + (r.height - component.getSize().height) / 2;
+ component.setLocation(x, y);
+ }
+
+ /**
+ * Try to load the Nimbus look and feel.
+ * <p/>
+ * @throws UnsupportedLookAndFeelException
+ * if nimbus is not applicable
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static void initNimbusLoookAndFeel() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+ for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(laf.getName())) {
+ UIManager.setLookAndFeel(laf.getClassName());
+ }
+ }
+ }
+
+ /**
+ * Load the ui.properties file and set in {@link UIManager} colors and icons found.
+ *
+ * @param defaultUIConfig le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path)
+ * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path)
+ *
+ * @throws IOException if could not load the ui.properties file
+ */
+ public static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException {
+
+ Properties p = new Properties();
+ log.info("loading default UI config " + defaultUIConfig);
+ p.load(SwingUtil.class.getResourceAsStream(defaultUIConfig));
+ if (log.isDebugEnabled()) {
+ log.debug(p.toString());
+ }
+ if (extraUIConfig != null) {
+ InputStream extraStream = SwingUtil.class.getResourceAsStream(extraUIConfig);
+ if (extraStream == null) {
+ log.warn("could not find extraUIConfig : " + extraUIConfig);
+ } else {
+ log.info("loading extra UI config " + extraUIConfig);
+ Properties p2 = new Properties(p);
+ p2.load(extraStream);
+ if (log.isDebugEnabled()) {
+ log.debug(p2.toString());
+ }
+ p.putAll(p2);
+ }
+ }
+ for (Entry<Object, Object> entry : p.entrySet()) {
+ String key = (String) entry.getKey();
+ if (key.startsWith(ICON_PREFIX)) {
+ ImageIcon icon;
+ try {
+ icon = createImageIcon((String) entry.getValue());
+ UIManager.put(key.substring(ICON_PREFIX.length()), icon);
+ } catch (Exception e) {
+ log.warn("could not load icon " + entry.getValue());
+ }
+ continue;
+ }
+ if (key.startsWith(COLOR_PREFIX)) {
+ String value = (String) entry.getValue();
+ String[] rgb = value.split(",");
+ UIManager.put(key.substring(COLOR_PREFIX.length()), new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2])));
+ }
+ }
+ }
+
+ /**
+ * Iterate the components of a {@link JTabbedPane} in natural order.
+ *
+ * Says using method {@link JTabbedPane#getComponent(int)}
+ * @param tabs the
+ * @return
+ * @since 1.4
+ */
+ public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) {
+ return new TabbedPaneIterator<Component>(false, tabs) {
+
+ @Override
+ protected Component get(int index, Component comp) {
+ return comp;
+ }
+ };
+ }
+
+ /**
+ * A simple iterator on a {@link JTabbedPane}.
+ *
+ * Implements the method {@link #get(int, java.awt.Component)} to obtain
+ * the data required given the component (or index).
+ *
+ * You can also inverse the order by usin the method {@link #reverse()}.
+ *
+ * Note: After the use of the method {@link #reverse()} the iterator returns
+ * to the first element.
+ *
+ * @param <O> the type of return elements.
+ * @since 1.4
+ */
+ public static abstract class TabbedPaneIterator<O> implements Iterator<O> {
+
+ final JTabbedPane tabs;
+ boolean reverse;
+ int index;
+ int increment;
+
+ protected abstract O get(int index, Component comp);
+
+ public TabbedPaneIterator(boolean reverse, JTabbedPane tabs) {
+ this.tabs = tabs;
+ setReverse(reverse);
+ }
+
+ public void reset() {
+ setReverse(reverse);
+ }
+
+ public int size() {
+ return tabs.getTabCount();
+ }
+
+ public TabbedPaneIterator<O> reverse() {
+ setReverse(!reverse);
+ return this;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return reverse ? index > 0 : index < tabs.getTabCount();
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public O next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ Component next = tabs.getComponentAt(index);
+ O result = get(index, next);
+ index += increment;
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ throw new IllegalStateException("not implemented for " + this);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "< reverse:" + reverse + ", index:" + index + ", size:" + tabs.getTabCount() + " >";
+ }
+
+ protected void setReverse(boolean reverse) {
+ if (reverse) {
+ index = tabs.getTabCount() - 1;
+ increment = -1;
+ } else {
+ index = 0;
+ increment = 1;
+ }
+ this.reverse = reverse;
+ }
+ }
+
+ public static JLabel newLabel(String text, Object iconKey, int aligment) {
+ Icon icon = null;
+ if (iconKey instanceof Icon) {
+ icon = (Icon) iconKey;
+ } else if (iconKey instanceof String) {
+ icon = jaxx.runtime.Util.getUIManagerActionIcon((String) iconKey);
+ }
+ JLabel result;
+ if (icon == null) {
+ result = new JLabel(text, aligment);
+ } else {
+ result = new JLabel(text, icon, aligment);
+ }
+ return result;
+ }
+
+ /**
+ * Gets the higest visible component in a ancestor hierarchy at
+ * specific x,y coordinates
+ * @param parent
+ * @param x
+ * @param y
+ * @return
+ */
+ public static Component getDeepestObjectAt(Component parent, int x, int y) {
+
+ if (parent instanceof Container) {
+ Container cont = (Container) parent;
+ // use a copy of 1.3 Container.findComponentAt
+ Component child = findComponentAt(cont, cont.getWidth(), cont.getHeight(), x, y);
+ if (child != null && child != cont) {
+ //log.info("child find : " + child.getName());
+ if (child instanceof JRootPane) {
+ JLayeredPane lp = ((JRootPane) child).getLayeredPane();
+ Rectangle b = lp.getBounds();
+ child = getDeepestObjectAt(lp, x - b.x, y - b.y);
+ }
+ if (child != null) {
+ return child;
+ }
+ }
+ }
+ // if the parent is not a Container then it might be a MenuItem.
+ // But even if it isn't a MenuItem just return the parent because
+ // that's a close as we can come.
+ return parent;
+ }
+
+ public static Component findComponentAt(Container cont, int width, int height, int x, int y) {
+ //log.info("container : " + cont.getName());
+ synchronized (cont.getTreeLock()) {
+
+ if (!((x >= 0) && (x < width) && (y >= 0) && (y < height) && cont.isVisible() && cont.isEnabled())) {
+ return null;
+ }
+
+ Component[] component = cont.getComponents();
+ int ncomponents = cont.getComponentCount();
+
+ // Two passes: see comment in sun.awt.SunGraphicsCallback
+ for (int i = 0; i < ncomponents; i++) {
+ Component comp = component[i];
+ Rectangle rect = null;
+
+ if (comp != null && !comp.isLightweight()) {
+ if (rect == null || rect.width == 0 || rect.height == 0) {
+ rect = comp.getBounds();
+ }
+ if (comp instanceof JXLayer<?>) {
+ JXLayer<?> layer = (JXLayer<?>) comp;
+ comp = layer.getView();
+ }
+ if (comp instanceof Container) {
+ comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y);
+ } else {
+ comp = comp.getComponentAt(x - rect.x, y - rect.y);
+ }
+ if (comp != null && comp.isVisible() && comp.isEnabled()) {
+ return comp;
+ }
+ }
+ }
+
+ for (int i = 0; i < ncomponents; i++) {
+ Component comp = component[i];
+ Rectangle rect = null;
+
+ if (comp != null && comp.isLightweight()) {
+ if (rect == null || rect.width == 0 || rect.height == 0) {
+ rect = comp.getBounds();
+ }
+ if (comp instanceof JXLayer<?>) {
+ JXLayer<?> layer = (JXLayer<?>) comp;
+ comp = layer.getView();
+ }
+ if (comp instanceof Container) {
+ comp = findComponentAt((Container) comp, rect.width, rect.height, x - rect.x, y - rect.y);
+ } else {
+ comp = comp.getComponentAt(x - rect.x, y - rect.y);
+ }
+ if (comp != null && comp.isVisible() && comp.isEnabled()) {
+ return comp;
+ }
+ }
+ }
+ return cont;
+ }
+ }
+
+ 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 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);
+ }
+
+ /**
+ * Open a link coming from a {@link HyperlinkEvent}.
+ *
+ * And try to open the link if an url in a browser.
+ *
+ * @param he the event to treate
+ * @since 1.6.0
+ */
+ public static void openLink(HyperlinkEvent he) {
+ if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+
+ if (Desktop.isDesktopSupported()) {
+ try {
+ URL u = he.getURL();
+ if (u.getProtocol().equalsIgnoreCase("mailto") || u.getProtocol().equalsIgnoreCase("http") || u.getProtocol().equalsIgnoreCase("ftp")) {
+ Desktop.getDesktop().browse(u.toURI());
+ }
+ } catch (IOException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error while opening link", e);
+ }
+ } catch (URISyntaxException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Error while opening link", e);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Expand all childs of a tree.
+ *
+ * @param tree the tree to expand
+ */
+ public static void expandTree(final JTree tree) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ int i = 0;
+ while (i < tree.getRowCount()) {
+ tree.expandRow(i++);
+ }
+ }
+ });
+ }
+
+ /**
+ * Add a listener of tree selection model to expand a new selected node
+ * when it is selected.
+ *
+ * @param tree the tree to treate
+ */
+ public static void addExpandOnClickListener(final JTree tree) {
+
+ tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(final TreeSelectionEvent e) {
+ TreeNode node = (TreeNode) e.getPath().getLastPathComponent();
+ if (node != null && !node.isLeaf()) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ for (TreePath path : e.getPaths()) {
+ if (e.isAddedPath(path) && !tree.isExpanded(path)) {
+ log.info("expand node [" + path + "]");
+ // will expand the node
+ tree.expandPath(path);
+ }
+ }
+ }
+ });
+ }
+ }
+ });
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -4,11 +4,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
-import javax.swing.JList;
import javax.swing.UIManager;
import java.awt.Component;
import java.awt.Dimension;
@@ -31,24 +29,20 @@
public static final String DEFAULT_ICON_PATH = "/icons/";
public static final String DEFAULT_ICON_PATH_PROPERTY = "default.icon.path";
-
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(Util.class);
-
-
// Maps root objects to lists of event listeners
private static Map<Object, WeakReference<List<EventListenerDescriptor>>> eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>();
private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>();
-
private static class EventListenerDescriptor {
- Class listenerClass;
+
+ Class<?> listenerClass;
String listenerMethodName;
String methodName;
Object eventListener;
}
-
/**
* Decodes the serialized representation of a JAXXObjectDescriptor. The string must be a byte-to-character mapping
* of the binary serialization data for a JAXXObjectDescriptor. See the comments in JAXXCompiler.createJAXXObjectDescriptorField
@@ -66,16 +60,13 @@
//descriptor.getBytes(0, descriptor.length(), data, 0);
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
return (JAXXObjectDescriptor) in.readObject();*/
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
}
}
-
public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor(String descriptor) {
try {
return (JAXXObjectDescriptor) Base64Coder.deserialize(descriptor, true);
@@ -86,16 +77,13 @@
//descriptor.getBytes(0, descriptor.length(), data, 0);
ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
return (JAXXObjectDescriptor) in.readObject();*/
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
throw new RuntimeException("Internal error: can't-happen error", e);
}
}
-
public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) {
WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer);
List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null;
@@ -131,22 +119,22 @@
if (listenerMethodName != null && listenerMethod == null) {
throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName());
}
- Class[] parameterTypes = listenerMethods.get(0).getParameterTypes();
+ Class<?>[] parameterTypes = listenerMethods.get(0).getParameterTypes();
Class<?> methodContainerClass = methodContainer.getClass();
final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes);
descriptor.eventListener = Proxy.newProxyInstance(listenerClass.getClassLoader(),
- new Class[]{listenerClass},
+ new Class<?>[]{listenerClass},
new InvocationHandler() {
+
+ @Override
public Object invoke(Object proxy, Method method, Object[] args) {
String methodName = method.getName();
if ((listenerMethodName == null && listenerMethods.contains(method)) || methodName.equals(listenerMethodName)) {
try {
return targetMethod.invoke(methodContainer, args);
- }
- catch (IllegalAccessException e) {
+ } catch (IllegalAccessException e) {
throw new RuntimeException(e);
- }
- catch (InvocationTargetException e) {
+ } catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
@@ -164,18 +152,15 @@
});
descriptors.add(descriptor);
return descriptor.eventListener;
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
-
public static Object getEventListener(Class<? extends EventListener> listenerClass, final Object methodContainer, final String methodName) {
return getEventListener(listenerClass, null, methodContainer, methodName);
}
-
public static DataBindingUpdateListener getDataBindingUpdateListener(JAXXObject object, String bindingName) {
WeakReference<List<DataBindingUpdateListener>> ref = dataBindingUpdateListeners.get(object);
List<DataBindingUpdateListener> listeners = ref == null ? null : ref.get();
@@ -194,7 +179,6 @@
return listener;
}
-
public static void setComponentWidth(Component component, int width) {
component.setSize(width, component.getHeight());
if (component instanceof JComponent) {
@@ -207,7 +191,6 @@
}
}
-
public static void setComponentHeight(Component component, int height) {
component.setSize(component.getWidth(), height);
if (component instanceof JComponent) {
@@ -220,55 +203,46 @@
}
}
-
public static boolean assignment(boolean value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static byte assignment(byte value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static short assignment(short value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static int assignment(int value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static long assignment(long value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static float assignment(float value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static double assignment(double value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static char assignment(char value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
}
-
public static java.lang.Object assignment(java.lang.Object value, String name, JAXXObject src) {
src.firePropertyChange(name.trim(), null, "dummy value");
return value;
@@ -346,24 +320,6 @@
}
}
- 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);
- }
- return super.getListCellRendererComponent(list, decorated, index, isSelected, cellHasFocus);
- }
- };
- }
-
public static ImageIcon createIcon(String path) {
java.net.URL imgURL = Util.class.getResource(path);
if (imgURL != null) {
@@ -400,7 +356,6 @@
return getUIManagerIcon("action." + key);
}
-
public static ImageIcon createActionIcon(String name) {
String iconPath = getIconPath();
return createIcon(iconPath + "action-" + name + ".png");
@@ -461,5 +416,4 @@
}
return iconPath;
}
-
}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Application.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,56 @@
+package jaxx.runtime.swing;
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import java.awt.GraphicsConfiguration;
+
+public class Application extends JFrame {
+ // Special: jaxxc will automatically add a main() method to any components which
+ // extend <Application>
+
+
+ public Application() {
+ }
+
+
+ public Application(GraphicsConfiguration gc) {
+ super(gc);
+ }
+
+
+ public Application(String title) {
+ super(title);
+ }
+
+
+ public Application(String title, GraphicsConfiguration gc) {
+ super(title, gc);
+ }
+
+
+ public void setLookAndFeel(String lookAndFeel) {
+ if (lookAndFeel.equals("system"))
+ lookAndFeel = UIManager.getSystemLookAndFeelClassName();
+ else if (lookAndFeel.equals("cross_platform"))
+ lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
+ try {
+ UIManager.setLookAndFeel(lookAndFeel);
+ if (isDisplayable())
+ SwingUtilities.updateComponentTreeUI(this);
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ catch (UnsupportedLookAndFeelException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Application.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,259 @@
+package jaxx.runtime.swing;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ *
+ * A JXLayer ui implementation that permits to block a component but still
+ * allow an action when clicking on the right-top icon painted on the layer.
+ *
+ * You can change the blocking and accepting icon.
+ *
+ * To hook an click on the layer's icon, you can :
+ *
+ * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li>
+ * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
+ * </ul>
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class BlockingLayerUI extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
+
+ public static final String CAN_CLICK_PROPERTY = "canClick";
+ public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
+ public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ public static final String BLOCK_PROPERTY = "block";
+ private static final long serialVersionUID = 1L;
+ /**
+ * Action to be treated when click on icon
+ */
+ protected Action acceptAction;
+ /**
+ * Icon when you can not click
+ */
+ protected BufferedImage blockIcon;
+ /**
+ * Icon when you can click
+ */
+ protected BufferedImage acceptIcon;
+ /**
+ * Optinal color to put fill background when blocking
+ */
+ protected Color blockingColor;
+ /**
+ * Internal state to known when we can accept click
+ */
+ protected boolean canClick;
+ /**
+ * A flag to enable or disable the use of the icon.
+ *
+ * If set to false, no icon will be displayed and no action
+ * will be possible.
+ *
+ * By default, this is active.
+ */
+ protected boolean useIcon = true;
+ /**
+ * Internal state when should block event and paint layer
+ */
+ protected boolean block;
+
+ public void setAcceptAction(Action acceptAction) {
+ this.acceptAction = acceptAction;
+ }
+
+ public void setAcceptIcon(ImageIcon acceptIcon) {
+ this.acceptIcon = prepareIcon(acceptIcon);
+ firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon);
+ setDirty(true);
+ }
+
+ public void setBlockIcon(ImageIcon blockIcon) {
+ this.blockIcon = prepareIcon(blockIcon);
+ firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon);
+ setDirty(true);
+ }
+
+ public void setCanClick(boolean canClick) {
+ boolean oldvalue = this.canClick;
+ this.canClick = canClick;
+ firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick);
+ if (oldvalue != canClick) {
+ setDirty(true);
+ }
+ }
+
+ public void setBlock(boolean block) {
+ boolean oldvalue = this.block;
+ this.block = block;
+ firePropertyChange(BLOCK_PROPERTY, oldvalue, block);
+ if (oldvalue != block) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean isDirty) {
+ super.setDirty(isDirty);
+ }
+
+ public void setBlockIcon(BufferedImage blockIcon) {
+ this.blockIcon = blockIcon;
+ }
+
+ public void setBlockingColor(Color blockingColor) {
+ this.blockingColor = blockingColor;
+ }
+
+ public BufferedImage getBlockIcon() {
+ return blockIcon;
+ }
+
+ protected BufferedImage getAcceptIcon() {
+ return acceptIcon;
+ }
+
+ public boolean isCanClick() {
+ return canClick;
+ }
+
+ public void setUseIcon(boolean useIcon) {
+ boolean oldvalue = this.useIcon;
+ this.useIcon = useIcon;
+ if (oldvalue != useIcon) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public BlockingLayerUI clone() {
+ BlockingLayerUI clone = new BlockingLayerUI();
+ clone.acceptAction = acceptAction;
+ clone.acceptIcon = acceptIcon;
+ clone.blockIcon = blockIcon;
+ clone.useIcon = useIcon;
+ clone.block = block;
+ clone.blockingColor = blockingColor;
+ clone.setCanClick(false);
+ return clone;
+ }
+
+ @Override
+ protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
+ if (useIcon || block) {
+ e.consume();
+ }
+ }
+
+ @Override
+ protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (useIcon) {
+ updateCanClickState(l, e);
+ }
+ if (useIcon || block) {
+ e.consume();
+ }
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (useIcon) {
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ updateCanClickState(l, e);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
+ }
+ if (useIcon || block) {
+ e.consume();
+ }
+
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ if (block && blockingColor != null) {
+ // to be in sync with the view if the layer has a border
+ /*Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+
+ g2.setColor(blockingColor);
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
+ if (useIcon && getCurrentIcon() != null) {
+ g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
+ }
+ }
+
+ protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (acceptAction != null) {
+ acceptAction.putValue("layer", l);
+ Component source = l.getView();
+ acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
+ }
+ }
+
+ protected BufferedImage getCurrentIcon() {
+ return canClick ? acceptIcon : blockIcon;
+ }
+
+ protected BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) {
+ // udpate toolTipText
+ Point layerLocation = l.getView().getLocation();
+ Point mousePoint = e.getPoint();
+ BufferedImage currentIcon = getCurrentIcon();
+ if (currentIcon == null) {
+ setCanClick(false);
+ return;
+ }
+ int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth();
+ int maxX = (int) layerLocation.getX() + l.getWidth();
+ int minY = 0;
+ int maxY = currentIcon.getHeight();
+ boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX;
+ accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY;
+ setCanClick(accept);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,217 @@
+package jaxx.runtime.swing;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ *
+ * A JXLayer ui implementation that permits to block a component but still
+ * allow an action when clicking everywhere on the layer.
+ *
+ * Moreover, an icon can be added on the right-top icon painted and changed
+ * when the mouse is over the layer.
+ *
+ * You can change the blocking and accepting icon.
+ *
+ * To hook an click on the layer's icon, you can :
+ *
+ * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li>
+ * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
+ * </ul>
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class BlockingLayerUI2 extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
+
+ public static final String CAN_CLICK_PROPERTY = "canClick";
+ public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
+ public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ private static final long serialVersionUID = 1L;
+ /**
+ * Action to be treated when click on icon
+ */
+ protected Action acceptAction;
+ /**
+ * Icon when you can not click
+ */
+ protected BufferedImage blockIcon;
+ /**
+ * Icon when you can click
+ */
+ protected BufferedImage acceptIcon;
+ /**
+ * Optinal color to put fill background when blocking
+ */
+ protected Color blockingColor;
+ /**
+ * Internal state to known when we can accept click
+ */
+ protected boolean canClick;
+
+ public void setAcceptAction(Action acceptAction) {
+ this.acceptAction = acceptAction;
+ }
+
+ public void setAcceptIcon(ImageIcon acceptIcon) {
+ this.acceptIcon = prepareIcon(acceptIcon);
+ firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon);
+ setDirty(true);
+ }
+
+ public void setBlockIcon(ImageIcon blockIcon) {
+ this.blockIcon = prepareIcon(blockIcon);
+ firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon);
+ setDirty(true);
+ }
+
+ public void setCanClick(boolean canClick) {
+ boolean oldvalue = this.canClick;
+ this.canClick = canClick;
+ firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick);
+ if (oldvalue != canClick) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean isDirty) {
+ super.setDirty(isDirty);
+ }
+
+ public void setBlockingColor(Color blockingColor) {
+ this.blockingColor = blockingColor;
+ }
+
+ public void setBlockIcon(BufferedImage blockIcon) {
+ this.blockIcon = blockIcon;
+ }
+
+ public BufferedImage getBlockIcon() {
+ return blockIcon;
+ }
+
+ protected BufferedImage getAcceptIcon() {
+ return acceptIcon;
+ }
+
+ public boolean isCanClick() {
+ return canClick;
+ }
+
+ @Override
+ public BlockingLayerUI2 clone() {
+ BlockingLayerUI2 clone = new BlockingLayerUI2();
+ clone.acceptAction = acceptAction;
+ clone.acceptIcon = acceptIcon;
+ clone.blockIcon = blockIcon;
+ clone.blockingColor = blockingColor;
+ clone.setCanClick(false);
+ return clone;
+ }
+
+ @Override
+ protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
+ e.consume();
+ }
+
+ @Override
+ protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
+ e.consume();
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ setCanClick(true);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
+ e.consume();
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ if (blockingColor != null) {
+ // to be in sync with the view if the layer has a border
+ /*Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+
+ g2.setColor(blockingColor);
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
+ if (getCurrentIcon() != null) {
+ g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
+ }
+ }
+
+ protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (acceptAction != null) {
+ acceptAction.putValue("layer", l);
+ Component source = l.getView();
+ acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
+ }
+ }
+
+ protected BufferedImage getCurrentIcon() {
+ return canClick ? acceptIcon : blockIcon;
+ }
+
+ protected BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) {
+ // udpate toolTipText
+ Point layerLocation = l.getView().getLocation();
+ Point mousePoint = e.getPoint();
+ BufferedImage currentIcon = getCurrentIcon();
+ if (currentIcon == null) {
+ setCanClick(false);
+ return;
+ }
+ int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth();
+ int maxX = (int) layerLocation.getX() + l.getWidth();
+ int minY = 0;
+ int maxY = currentIcon.getHeight();
+ boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX;
+ accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY;
+ setCanClick(accept);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -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;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,221 @@
+package jaxx.runtime.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * An override of the awt {@link java.awt.CardLayout}.
+ * <p/>
+ * Because in the original layout is not overridable : everything is package level accessible.
+ * <p/>
+ * This new class offers to test if a constrains (as a Serializable) is actually dealed by the layout,
+ * via the method {@link #contains(java.io.Serializable)}.
+ * <p/>
+ * We had also another method to obtain the current visible component in a container layouted by the class,
+ * via the method {@link #getVisibleComponent(java.awt.Container)}.
+ *
+ * @author chemit
+ * @version 1.0
+ */
+public class CardLayout2 extends CardLayout {
+
+ /** log */
+ static private Log log = LogFactory.getLog(CardLayout2.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /** list of already loaded context (since the {@link #vector} attribute is package visible... */
+ protected List<Serializable> contexts = new LinkedList<Serializable>();
+
+ /**
+ * A flag to compute dimension only on visible component.
+ * <p/>
+ * This is usefull when we only care of the visible component.
+ */
+ protected boolean useOnlyVisibleComponentDimension;
+
+ @Override
+ public void addLayoutComponent(Component comp, Object constraints) {
+ super.addLayoutComponent(comp, constraints);
+ contexts.add((Serializable) constraints);
+ if (log.isDebugEnabled()) {
+ log.debug(this + " new constraints : " + constraints);
+ }
+ }
+
+ /**
+ * Test if a constrains is contained in the layout.
+ *
+ * @param constraints l'identifiant a tester
+ * @return <code>true</code> si l'identifiant est deja present dans le layout, <code>false</code> autrement.
+ */
+ public boolean contains(Serializable constraints) {
+ return contexts.contains(constraints);
+ }
+
+ /**
+ * Obtain the visible component in the container.
+ *
+ * @param container the container using this layout
+ * @return the component visible in the container.
+ */
+ public Component getVisibleComponent(Container container) {
+ if (container.getLayout() != this) {
+ throw new IllegalArgumentException("the container is not managed by the current layout");
+ }
+ for (Component component : container.getComponents()) {
+ if (component.isVisible()) {
+ return component;
+ }
+ }
+ // no component actually visible
+ return null;
+ }
+
+ public Component getComponent(Container container, String constraints) {
+ if (container.getLayout() != this) {
+ throw new IllegalArgumentException("the container is not manage by the current layout");
+ }
+ if (!contexts.contains(constraints)) {
+ throw new IllegalArgumentException("the constraints '" + constraints + "' is not supported by this layout : " + contexts);
+ }
+ int index = contexts.indexOf(constraints);
+ return container.getComponents()[index];
+ }
+
+ /**
+ * Determines the preferred size of the container argument using
+ * this card layout.
+ *
+ * @param parent the parent container in which to do the layout
+ * @return the preferred dimensions to lay out the subcomponents
+ * of the specified container
+ * @see java.awt.Container#getPreferredSize
+ * @see java.awt.CardLayout#minimumLayoutSize
+ */
+ @Override
+ public Dimension preferredLayoutSize(Container parent) {
+ Dimension dimension = null;
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(parent);
+ if (comp != null) {
+ dimension = comp.getPreferredSize();
+ }
+ }
+ if (dimension == null) {
+ dimension = super.preferredLayoutSize(parent);
+ }
+ return dimension;
+ }
+
+ /**
+ * Calculates the minimum size for the specified panel.
+ *
+ * @param parent the parent container in which to do the layout
+ * @return the minimum dimensions required to lay out the
+ * subcomponents of the specified container
+ * @see java.awt.Container#doLayout
+ * @see java.awt.CardLayout#preferredLayoutSize
+ */
+ @Override
+ public Dimension minimumLayoutSize(Container parent) {
+ Dimension dimension = null;
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(parent);
+ if (comp != null) {
+ dimension = comp.getMinimumSize();
+ }
+ }
+ if (dimension == null) {
+ dimension = super.minimumLayoutSize(parent);
+ }
+ return dimension;
+ }
+
+ /**
+ * Returns the maximum dimensions for this layout given the components
+ * in the specified target container.
+ *
+ * @param target the component which needs to be laid out
+ * @see java.awt.Container
+ * @see #minimumLayoutSize
+ * @see #preferredLayoutSize
+ */
+ @Override
+ public Dimension maximumLayoutSize(Container target) {
+ Dimension dimension = null;
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(target);
+ if (comp != null) {
+ dimension = comp.getMaximumSize();
+ }
+ }
+ if (dimension == null) {
+ dimension = super.maximumLayoutSize(target);
+ }
+ return dimension;
+ }
+
+ /**
+ * Lays out the specified container using this card layout.
+ * <p/>
+ * Each component in the <code>parent</code> container is reshaped
+ * to be the size of the container, minus space for surrounding
+ * insets, horizontal gaps, and vertical gaps.
+ *
+ * @param parent the parent container in which to do the layout
+ * @see java.awt.Container#doLayout
+ */
+ @Override
+ public void layoutContainer(Container parent) {
+ if (useOnlyVisibleComponentDimension) {
+ Component comp = getVisibleComponent(parent);
+ if (comp != null) {
+ //dimension = comp.getMinimumSize();
+ Insets insets = parent.getInsets();
+ comp.setBounds(getHgap() + insets.left, getVgap() + insets.top,
+ parent.getWidth() - (getHgap() * 2 + insets.left + insets.right),
+ parent.getHeight() - (getVgap() * 2 + insets.top + insets.bottom));
+ } else {
+ super.layoutContainer(parent);
+ }
+ } else {
+ super.layoutContainer(parent);
+ }
+ }
+
+ public boolean isUseOnlyVisibleComponentDimension() {
+ return useOnlyVisibleComponentDimension;
+ }
+
+ public void setUseOnlyVisibleComponentDimension(boolean useOnlyVisibleComponentDimension) {
+ this.useOnlyVisibleComponentDimension = useOnlyVisibleComponentDimension;
+ }
+
+ /**
+ * remove from cardlayout and linked container all his components.
+ *
+ * @param parent the parent container linked with the layout
+ */
+ public void reset(Container parent) {
+ if (parent.getLayout() != this) {
+ throw new IllegalArgumentException("wrong parent for CardLayout");
+ }
+ for (Component component : parent.getComponents()) {
+ removeLayoutComponent(component);
+ parent.remove(component);
+ }
+ contexts.clear();
+
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,99 @@
+package jaxx.runtime.swing;
+
+import java.awt.Container;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Une extension de {@link CardLayout2} pour pouvoir automatiquement afficher un
+ * contenu à partir de la propriété {@link #selected}.
+ *
+ * Ainsi, en changeant cette propriété via la méthode {@link #setSelected(String)},
+ * le contenu sera changé automatiquement, ce qui permet une utilisation direct
+ * dans jaxx sans à avoir à écrire d'écouteur.
+ *
+ * @author tony
+ * @since 1.3
+ * @see CardLayout2
+ */
+public class CardLayout2Ext extends CardLayout2 {
+
+ /** log */
+ static private Log log = LogFactory.getLog(CardLayout2.class);
+ private static final long serialVersionUID = 1L;
+ public static final String SELECTED_PROPERTY_NAME = "selected";
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+ /**
+ * le contenu sélectionné
+ */
+ protected String selected;
+ private String containerName;
+ private JAXXObject ui;
+ private Container container;
+
+ public CardLayout2Ext(JAXXObject ui, String containerName) {
+ pcs = new PropertyChangeSupport(this);
+ this.ui = ui;
+ this.containerName = containerName;
+ }
+
+ public String getSelected() {
+ return selected;
+ }
+
+ public String getPreviousSelected() {
+ int index = contexts.indexOf(selected);
+ if (index < 1) {
+ return null;
+ }
+ return contexts.get(index - 1) + "";
+ }
+
+ public String getNextSelected() {
+ int index = contexts.indexOf(selected);
+ if (index >= contexts.size()) {
+ return null;
+ }
+ return contexts.get(index + 1) + "";
+ }
+
+ public void setSelected(String selected) {
+ this.selected = selected;
+ show(getContainer(), selected);
+ }
+
+ public Container getContainer() {
+ if (container == null) {
+ container = (Container) ui.getObjectById(containerName);
+ }
+ return container;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/GBC.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,151 @@
+/**
+ * *##% Lutin I18n Editor
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+/*
+GBC - A convenience class to tame the GridBagLayout
+
+Copyright (C) 2002 Cay S. Horstmann (http://horstmann.com)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package jaxx.runtime.swing;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+
+/**
+ * This class simplifies the use of the GridBagConstraints
+ * class.
+ */
+public class GBC extends GridBagConstraints {
+ private static final long serialVersionUID = -3626882543530638704L;
+
+ /**
+ * Constructs a GBC with a given gridx and gridy position and
+ * all other grid bag constraint values set to the default.
+ *
+ * @param gridx the gridx position
+ * @param gridy the gridy position
+ */
+ public GBC(int gridx, int gridy) {
+ this.gridx = gridx;
+ this.gridy = gridy;
+ }
+
+ /**
+ * Constructs a GBC with given gridx, gridy, gridwidth, gridheight
+ * and all other grid bag constraint values set to the default.
+ *
+ * @param gridx the gridx position
+ * @param gridy the gridy position
+ * @param gridwidth the cell span in x-direction
+ * @param gridheight the cell span in y-direction
+ */
+ public GBC(int gridx, int gridy, int gridwidth, int gridheight) {
+ this.gridx = gridx;
+ this.gridy = gridy;
+ this.gridwidth = gridwidth;
+ this.gridheight = gridheight;
+ }
+
+ /**
+ * Sets the anchor.
+ *
+ * @param anchor the anchor value
+ * @return this object for further modification
+ */
+ public GBC setAnchor(int anchor) {
+ this.anchor = anchor;
+ return this;
+ }
+
+ /**
+ * Sets the fill direction.
+ *
+ * @param fill the fill direction
+ * @return this object for further modification
+ */
+ public GBC setFill(int fill) {
+ this.fill = fill;
+ return this;
+ }
+
+ /**
+ * Sets the cell weights.
+ *
+ * @param weightx the cell weight in x-direction
+ * @param weighty the cell weight in y-direction
+ * @return this object for further modification
+ */
+ public GBC setWeight(double weightx, double weighty) {
+ this.weightx = weightx;
+ this.weighty = weighty;
+ return this;
+ }
+
+ /**
+ * Sets the insets of this cell.
+ *
+ * @param distance the spacing to use in all directions
+ * @return this object for further modification
+ */
+ public GBC setInsets(int distance) {
+ this.insets = new Insets(distance, distance, distance, distance);
+ return this;
+ }
+
+ /**
+ * Sets the insets of this cell.
+ *
+ * @param top the spacing to use on top
+ * @param left the spacing to use to the left
+ * @param bottom the spacing to use on the bottom
+ * @param right the spacing to use to the right
+ * @return this object for further modification
+ */
+ public GBC setInsets(int top, int left, int bottom, int right) {
+ this.insets = new Insets(top, left, bottom, right);
+ return this;
+ }
+
+ /**
+ * Sets the internal padding
+ *
+ * @param ipadx the internal padding in x-direction
+ * @param ipady the internal padding in y-direction
+ * @return this object for further modification
+ */
+ public GBC setIpad(int ipadx, int ipady) {
+ this.ipadx = ipadx;
+ this.ipady = ipady;
+ return this;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/GBC.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/HBox.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import java.awt.Insets;
+
+/**
+ * Panel which uses an {@link HBoxLayout} by default.
+ *
+ * @author Ethan Nicholas
+ */
+public class HBox extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ public static final String SPACING_PROPERTY = "spacing";
+ public static final String MARGIN_PROPERTY = "margin";
+ public static final String HORIZONTAL_ALIGNMENT_PROPERTY = "horizontalAlignment";
+ public static final String VERTICAL_ALIGNMENT_PROPERTY = "verticalAlignment";
+ private Insets margin;
+
+ public HBox() {
+ super(new HBoxLayout());
+ }
+
+ /**
+ * Returns the spacing between components, in pixels. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @return spacing between components
+ */
+ public int getSpacing() {
+ return ((HBoxLayout) getLayout()).getSpacing();
+ }
+
+ /**
+ * Sets the spacing between components. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @param spacing new spacing value
+ */
+ public void setSpacing(int spacing) {
+ int oldValue = getSpacing();
+ ((HBoxLayout) getLayout()).setSpacing(spacing);
+ firePropertyChange(SPACING_PROPERTY, oldValue, spacing);
+ revalidate();
+ }
+
+ public int getHorizontalAlignment() {
+ return ((HBoxLayout) getLayout()).getHorizontalAlignment();
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ int oldValue = getHorizontalAlignment();
+ ((HBoxLayout) getLayout()).setHorizontalAlignment(horizontalAlignment);
+ firePropertyChange(HORIZONTAL_ALIGNMENT_PROPERTY, oldValue, horizontalAlignment);
+ revalidate();
+ }
+
+ public int getVerticalAlignment() {
+ return ((HBoxLayout) getLayout()).getVerticalAlignment();
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ int oldValue = getVerticalAlignment();
+ ((HBoxLayout) getLayout()).setVerticalAlignment(verticalAlignment);
+ firePropertyChange(VERTICAL_ALIGNMENT_PROPERTY, oldValue, verticalAlignment);
+ revalidate();
+ }
+
+ public Insets getMargin() {
+ return margin;
+ }
+
+ public void setMargin(Insets margin) {
+ Insets oldValue = this.margin;
+ this.margin = (Insets) margin.clone();
+ firePropertyChange(MARGIN_PROPERTY, oldValue, margin);
+ }
+
+ @Override
+ public Insets getInsets() {
+ Insets result = super.getInsets();
+ if (margin != null) {
+ result.top += margin.top;
+ result.left += margin.left;
+ result.right += margin.right;
+ result.bottom += margin.bottom;
+ }
+ return result;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBox.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/HBoxLayout.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.SwingConstants;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Horizontal box layout. The layout rules followed by this class are quite different than the core BoxLayout class,
+ * and in general represent a more useful algorithm.
+ *
+ * @author Ethan Nicholas
+ */
+public class HBoxLayout implements LayoutManager {
+
+ private int spacing = 6;
+ private int horizontalAlignment = SwingConstants.LEFT;
+ private int verticalAlignment = SwingConstants.TOP;
+
+ public int getSpacing() {
+ return spacing;
+ }
+
+ public void setSpacing(int spacing) {
+ this.spacing = spacing;
+ }
+
+ public int getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public int getVerticalAlignment() {
+ return verticalAlignment;
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ this.verticalAlignment = verticalAlignment;
+ }
+
+ @Override
+ public void addLayoutComponent(String name, Component comp) {
+ }
+
+ @Override
+ public void layoutContainer(Container parent) {
+ Insets insets = parent.getInsets();
+ int parentHeight = parent.getSize().height - insets.top - insets.bottom;
+ int count = parent.getComponentCount();
+ Dimension preferredSize = parent.getPreferredSize();
+ int x;
+ switch (horizontalAlignment) {
+ case SwingConstants.LEFT:
+ x = insets.left;
+ break;
+ case SwingConstants.CENTER:
+ x = insets.left + (parent.getWidth() - preferredSize.width) / 2;
+ break;
+ case SwingConstants.RIGHT:
+ x = insets.left + (parent.getWidth() - preferredSize.width);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid horizontal alignment: " + horizontalAlignment);
+ }
+
+ for (int i = 0; i < count; i++) {
+ Component component = parent.getComponent(i);
+ Dimension childPreferredSize = component.getPreferredSize();
+ int height = Math.min(childPreferredSize.height, parentHeight);
+ int y;
+ switch (verticalAlignment) {
+ case SwingConstants.TOP:
+ y = insets.top;
+ break;
+ case SwingConstants.CENTER:
+ y = insets.top + (parentHeight - childPreferredSize.height) / 2;
+ break;
+ case SwingConstants.BOTTOM:
+ y = insets.top + (parentHeight - childPreferredSize.height);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid vertical alignment: " + verticalAlignment);
+ }
+ component.setBounds(x, y, childPreferredSize.width, height);
+ x += childPreferredSize.width + spacing;
+ }
+ }
+
+ @Override
+ public Dimension minimumLayoutSize(Container parent) {
+ int width = (parent.getComponentCount() - 1) * spacing;
+ int height = 0;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension minimumSize = parent.getComponent(i).getMinimumSize();
+ width += minimumSize.width;
+ height = Math.max(height, minimumSize.height);
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public Dimension preferredLayoutSize(Container parent) {
+ int width = (parent.getComponentCount() - 1) * spacing;
+ int height = 0;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension preferredSize = parent.getComponent(i).getPreferredSize();
+ width += preferredSize.width;
+ height = Math.max(height, preferredSize.height);
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public void removeLayoutComponent(Component comp) {
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxLayout.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,66 @@
+package jaxx.runtime.swing;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import java.awt.Component;
+
+/**
+ * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
+ * the text is I18nalize.
+ *
+ * @author chemit
+ */
+public class I18nTableCellRenderer implements TableCellRenderer {
+
+ /** i18n keys of libelles to display */
+ protected final String[] keys;
+
+ /** i18n keys of toolTipTexts to display */
+ protected final String[] tips;
+
+ /** the delegate cell renderer */
+ protected TableCellRenderer delegate;
+
+ public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
+ this.delegate = delegate;
+ if (keysAndTips.length == 0) {
+ throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
+ }
+ if (keysAndTips.length % 2 == 1) {
+ throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
+ }
+ int size = keysAndTips.length / 2;
+ this.keys = new String[size];
+ this.tips = new String[size];
+ for (int i = 0; i < size; i++) {
+ this.keys[i] = keysAndTips[2 * i];
+ this.tips[i] = keysAndTips[2 * i + 1];
+ }
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ if (column > keys.length) {
+ throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
+ }
+ TableColumn col = table.getColumn(table.getColumnName(column));
+ int index = col.getModelIndex();
+ value = _(keys[index]);
+ JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ rendererComponent.setToolTipText(_(tips[index]));
+ return rendererComponent;
+ }
+
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public String[] getTips() {
+ return tips;
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Item.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.event.SwingPropertyChangeSupport;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.List;
+
+// This needs to be split into two classes, Item and TreeItem
+/**
+ * An item in a component such as <code>JComboBox</code> or <code>JTree</code>. The <code>Item</code>
+ * class corresponds to the <code><item></code> tag in JAXX source files.
+ */
+public class Item {
+
+ public static final String LABEL_PROPERTY = "label";
+ public static final String VALUE_PROPERTY = "value";
+ public static final String SELECTED_PROPERTY = "selected";
+ private String id;
+ private String label;
+ private Object value;
+ private boolean selected;
+ private List<Item> children;
+ private Item parent;
+ private PropertyChangeSupport propertyChangeSupport;
+
+ /**
+ * Creates a new Item. This should only be called from compiled JAXX files.
+ *
+ * @param id the item's ID
+ * @param label the string that should be used to represent the item visually
+ * @param value the item's actual value
+ * @param selected <code>true</code> if the item should be selected by default
+ */
+ public Item(String id, String label, Object value, boolean selected) {
+ this.id = id;
+ this.label = label;
+ this.value = value;
+ this.selected = selected;
+ }
+
+ /**
+ * Returns this item's ID.
+ *
+ * @return the JAXX ID attribute
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the string that should be used to represent the item at display time. If <code>null</code>,
+ * <code>String.valueOf(getValue())</code> will be used instead.
+ *
+ * @return this item's display string
+ * @see #setLabel
+ */
+ public String getLabel() {
+ return label;
+ }
+
+ /**
+ * Sets the item's display string. If <code>null, String.valueOf(getValue())</code> will be used instead.
+ *
+ * @param label the new display string
+ * @see #getLabel
+ */
+ public void setLabel(String label) {
+ String oldLabel = this.label;
+ this.label = label;
+ firePropertyChange(LABEL_PROPERTY, oldLabel, label);
+ }
+
+ /**
+ * Returns the item's actual value as it appears in the component's model. The <code>Item</code> itself is not
+ * visible from the model, only the value.
+ *
+ * @return the item's value
+ * @see #setValue
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the item's value as it appears in the component's model. The <code>Item</code> itself is not
+ * visible from the model, only the value.
+ *
+ * @param value the new value
+ * @see #getValue
+ */
+ public void setValue(Object value) {
+ Object oldValue = this.value;
+ this.value = value;
+ firePropertyChange(VALUE_PROPERTY, oldValue, value);
+ }
+
+ /**
+ * Returns <code>true</code> if this item is currently selected. This is a bound property.
+ *
+ * @return <code>true</code> if item is selected
+ * @see #setSelected
+ */
+ public boolean isSelected() {
+ return selected;
+ }
+
+ /**
+ * Sets the item's selection state. This is a bound property.
+ *
+ * @param selected the new selection state
+ * @see #isSelected
+ */
+ public void setSelected(boolean selected) {
+ boolean oldSelected = this.selected;
+ this.selected = selected;
+ firePropertyChange(SELECTED_PROPERTY, oldSelected, selected);
+ }
+
+ /**
+ * Adds a new child node (Items can be nested in trees).
+ *
+ * @param item the new child item
+ */
+ public void addChild(Item item) {
+ if (children == null) {
+ children = new ArrayList<Item>();
+ }
+ children.add(item);
+ item.parent = this;
+ }
+
+ /**
+ * Remove child node a new child node
+ *
+ * @param item to remove
+ */
+ public void removeChild(Item item) {
+ if (children != null) {
+ children.remove(item);
+ }
+ }
+
+ /**
+ * Remove all childs nodes
+ *
+ * @param list of items to remove
+ */
+ public void removeChilds(List<Item> items) {
+ if (children != null) {
+ children.removeAll(items);
+ }
+ }
+
+ /**
+ * Returns a list of this item's children.
+ *
+ * @return a list of all nested child nodes
+ */
+ public List<Item> getChildren() {
+ if (children == null) {
+ children = new ArrayList<Item>();
+ }
+ return children;
+ }
+
+ /**
+ * Returns the <code>Item</code> containing this <code>Item</code>, or <code>null</code> for a top-level
+ * <code>Item</code>.
+ *
+ * @return the item parent (or null)
+ */
+ public Item getParent() {
+ return parent;
+ }
+
+ /**
+ * Set the parent of this item
+ *
+ * @return the item parent (or null)
+ */
+ public void setParent(Item parent) {
+ this.parent = parent;
+ }
+
+ private PropertyChangeSupport getPropertyChangeSupport() {
+ if (propertyChangeSupport == null) {
+ propertyChangeSupport = new SwingPropertyChangeSupport(this);
+ }
+ return propertyChangeSupport;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(property, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(property, listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (propertyChangeSupport != null) {
+ getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + value + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.AbstractButton;
+import javax.swing.ButtonGroup;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.swing.event.EventListenerList;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Enumeration;
+
+public class JAXXButtonGroup extends ButtonGroup {
+
+ public static final String SELECTED_VALUE_PROPERTY = "selectedValue";
+ public static final String BUTTON8GROUP_CLIENT_PROPERTY = "$buttonGroup";
+ public static final String VALUE_CLIENT_PROPERTY = "$value";
+ public static final String SELECTED_TIP_CLIENT_PROPERTY = "$selected.toolTipText";
+ public static final String NOT_SELECTED_TIP_CLIENT_PROPERTY = "$not.selected.toolTipText";
+ protected EventListenerList listenerList = new EventListenerList();
+ private PropertyChangeSupport propertyChangeSupport;
+ private transient Object selectedValue;
+ protected boolean useToolTipText;
+ protected transient ChangeEvent changeEvent = new ChangeEvent(this);
+ private transient ChangeListener changeListener = new ChangeListener() {
+
+ @Override
+ public void stateChanged(ChangeEvent e) {
+ updateSelectedValue();
+ if (useToolTipText) {
+ updateToolTipText();
+ }
+ }
+ };
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void add(AbstractButton button) {
+ super.add(button);
+ button.addChangeListener(changeListener);
+ updateSelectedValue();
+ }
+
+ @Override
+ public void remove(AbstractButton button) {
+ super.remove(button);
+ button.removeChangeListener(changeListener);
+ updateSelectedValue();
+ }
+
+ public void updateSelectedValue() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ if (button.isSelected()) {
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY);
+ if (buttonValue != getSelectedValue()) {
+ setSelectedValue(buttonValue);
+ }
+ }
+ }
+ }
+
+ public void updateToolTipText() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ String key = button.isSelected() ? SELECTED_TIP_CLIENT_PROPERTY : NOT_SELECTED_TIP_CLIENT_PROPERTY;
+ button.setToolTipText((String) button.getClientProperty(key));
+ }
+ }
+
+ public boolean isUseToolTipText() {
+ return useToolTipText;
+ }
+
+ public Object getSelectedValue() {
+ return selectedValue;
+ }
+
+ public AbstractButton getSelectedButton() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ if (button.isSelected()) {
+ return button;
+ }
+ }
+ return null;
+ }
+
+ public AbstractButton getButton(Object value) {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY);
+ if (value.equals(buttonValue)) {
+ return button;
+ }
+ }
+ return null;
+ }
+
+ public void setSelectedValue(Object value) {
+ Object oldValue = getSelectedValue();
+ this.selectedValue = value;
+ firePropertyChange(oldValue);
+ }
+
+ public void setUseToolTipText(boolean useToolTipText) {
+ this.useToolTipText = useToolTipText;
+ }
+
+ public void setSelectedButton(Object value) {
+ setSelectedValue(value);
+ if (value == null) {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ setSelected(button.getModel(), false);
+ }
+ return;
+ }
+
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY);
+ if (value.equals(buttonValue)) {
+ button.setSelected(true);
+ break;
+ }
+ }
+ }
+
+ protected PropertyChangeSupport getPropertyChangeSupport() {
+ if (propertyChangeSupport == null) {
+ propertyChangeSupport = new PropertyChangeSupport(this);
+ }
+ return propertyChangeSupport;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(property, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(property, listener);
+ }
+
+ private void firePropertyChange(Object oldValue) {
+ if (propertyChangeSupport != null) {
+ getPropertyChangeSupport().firePropertyChange(SELECTED_VALUE_PROPERTY,
+ oldValue, getSelectedValue());
+ }
+ fireStateChanged();
+ }
+
+ /**
+ * Adds a <code>ChangeListener</code> to the button.
+ *
+ * @param l the listener to be added
+ */
+ public void addChangeListener(ChangeListener l) {
+ listenerList.add(ChangeListener.class, l);
+ }
+
+ /**
+ * Removes a ChangeListener from the button.
+ *
+ * @param l the listener to be removed
+ */
+ public void removeChangeListener(ChangeListener l) {
+ listenerList.remove(ChangeListener.class, l);
+ }
+
+ /**
+ * Returns an array of all the <code>ChangeListener</code>s added
+ * to this AbstractButton with addChangeListener().
+ *
+ * @return all of the <code>ChangeListener</code>s added or an empty
+ * array if no listeners have been added
+ * @since 1.4
+ */
+ public ChangeListener[] getChangeListeners() {
+ return listenerList.getListeners(ChangeListener.class);
+ }
+
+ /**
+ * Notifies all listeners that have registered interest for
+ * notification on this event type. The event instance
+ * is lazily created.
+ *
+ * @see EventListenerList
+ */
+ protected void fireStateChanged() {
+ // Guaranteed to return a non-null array
+ Object[] listeners = listenerList.getListenerList();
+ // Process the listeners last to first, notifying
+ // those that are interested in this event
+ for (int i = listeners.length - 2; i >= 0; i -= 2) {
+ if (listeners[i] == ChangeListener.class) {
+ // Lazily create the event:
+ if (changeEvent == null) {
+ changeEvent = new ChangeEvent(this);
+ }
+ ((ChangeListener) listeners[i + 1]).stateChanged(changeEvent);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.ListModel;
+import java.awt.Component;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class JAXXComboBox extends JComboBox {
+
+ private static final long serialVersionUID = 1L;
+
+ public class JAXXComboBoxModel extends AbstractListModel implements ComboBoxModel {
+
+ private List<Item> items;
+ private Object selectedItem;
+ private static final long serialVersionUID = -8940733376638766414L;
+
+ public JAXXComboBoxModel(List<Item> items) {
+ this.items = items;
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) {
+ Item item = (Item) e.getSource();
+ int itemIndex = JAXXComboBoxModel.this.items.indexOf(item);
+ // TODO: fix cut-and-pasting badness
+ int[] oldSelection = new int[]{getSelectedIndex()};
+ int[] newSelection;
+ int index = -1;
+ for (int i = 0; i < oldSelection.length; i++) {
+ if (oldSelection[i] == itemIndex) {
+ index = i;
+ break;
+ }
+ }
+ if (item.isSelected()) {
+ if (index != -1) // it was already selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length + 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, oldSelection.length);
+ newSelection[newSelection.length - 1] = itemIndex;
+ } else {
+ if (index == -1) // it already wasn't selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length - 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, index);
+ System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index);
+ }
+ if (newSelection.length > 0) {
+ setSelectedIndex(newSelection[0]);
+ }
+ } else {
+ // TODO: more cut-and-pasting badness
+ for (int i = 0; i < getSize(); i++) {
+ if (getElementAt(i) == ((Item) e.getSource()).getValue()) {
+ fireContentsChanged(JAXXComboBoxModel.this, i, i);
+ if (getSelectedIndex() == i) {
+ fireItemStateChanged(new ItemEvent(JAXXComboBox.this, ItemEvent.ITEM_STATE_CHANGED, getElementAt(i), ItemEvent.DESELECTED));
+ }
+ return;
+ }
+ }
+ }
+ }
+ };
+ for (Item item : items) {
+ item.addPropertyChangeListener(listener);
+ }
+ }
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ @Override
+ public Object getElementAt(int i) {
+ return items.get(i).getValue();
+ }
+
+ @Override
+ public int getSize() {
+ return items.size();
+ }
+
+ @Override
+ public Object getSelectedItem() {
+ return selectedItem;
+ }
+
+ @Override
+ public void setSelectedItem(Object selectedItem) {
+ if ((this.selectedItem != null && !this.selectedItem.equals(selectedItem)) ||
+ this.selectedItem == null && selectedItem != null) {
+ this.selectedItem = selectedItem;
+ fireContentsChanged(this, -1, -1);
+ }
+ }
+ }
+
+ public JAXXComboBox() {
+ setRenderer(new DefaultListCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ ListModel model = list.getModel();
+ if (model instanceof JAXXComboBoxModel) {
+ List/*<Item>*/ items = ((JAXXComboBoxModel) model).items;
+ Item item = null;
+ if (index == -1) {
+ for (Object item1 : items) {
+ Item testItem = (Item) item1;
+ if (testItem.getValue() == value) {
+ item = testItem;
+ break;
+ }
+ }
+ } else {
+ item = (Item) items.get(index);
+ }
+
+ if (item != null) {
+ String label = item.getLabel();
+ if (label != null) {
+ value = label;
+ }
+ }
+ }
+ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+ });
+
+ addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ ListModel model = getModel();
+ if (model instanceof JAXXComboBoxModel) {
+ List<Item> items = ((JAXXComboBoxModel) model).items;
+ for (int i = items.size() - 1; i >= 0; i--) {
+ boolean selected = getSelectedIndex() == i;
+ Item item = items.get(i);
+ if (selected != item.isSelected()) {
+ item.setSelected(selected);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ * @param methodName method to invoke to display data's name
+ */
+ public void fillComboBox(Collection<?> data, Object select, String methodName) {
+ // prepare method to use
+ Method m;
+ try {
+ m = select.getClass().getMethod(methodName);
+ m.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("could not find method " + methodName + " on " + select.getClass());
+ }
+
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = o.equals(select);
+ try {
+ items.add(new Item(o.toString(), (String) m.invoke(o), o, selected));
+ } catch (IllegalAccessException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ }
+ }
+ setItems(items);
+ }
+
+ // this way we can keep it marked protected and still allow code in this file to call it
+ @Override
+ protected void fireItemStateChanged(ItemEvent e) {
+ super.fireItemStateChanged(e);
+ }
+
+ public void setItems(List<Item> items) {
+ setModel(new JAXXComboBoxModel(items));
+ List<Integer> selectedIndexList = new ArrayList<Integer>();
+ for (int i = 0; i < items.size(); i++) {
+ if (items.get(i).isSelected()) {
+ selectedIndexList.add(i);
+ }
+ }
+ int[] selectedIndices = new int[selectedIndexList.size()];
+ for (int i = 0; i < selectedIndexList.size(); i++) {
+ selectedIndices[i] = selectedIndexList.get(i);
+ }
+ if (selectedIndices.length > 0) {
+ setSelectedIndex(selectedIndices[0]);
+ }
+ }
+
+ public List<Item> getItems() {
+ if (getModel() instanceof JAXXComboBoxModel) {
+ return ((JAXXComboBoxModel) getModel()).getItems();
+ }
+ return null;
+ }
+
+ public void setSelectedItem(Item item) {
+ //TC-20092004 Anomalie #73 fix npe when want to call with a null
+ // value
+ super.setSelectedItem(item == null ? null : item.getValue());
+ }
+
+ public Item getSelectedJaxxItem() {
+ Object selected = super.getSelectedItem();
+ return findItem(selected);
+ }
+
+ public Item findItem(Object value) {
+ List<Item> items = getItems();
+ if (items != null) {
+ for (Item i : items) {
+ if (i.getValue().equals(value)) {
+ return i;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void addItem(Item item) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.add(item);
+ setItems(items);
+ }
+ }
+
+ public void addAllItems(Collection<Item> itemsToAdd) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.addAll(itemsToAdd);
+ setItems(items);
+ }
+ }
+
+ public void removeItem(Item item) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.remove(item);
+ setItems(items);
+ }
+ }
+
+ public void removeAllItems(Collection<Item> itemsToRemove) {
+ List<Item> items = getItems();
+ if (items != null) {
+ items.removeAll(itemsToRemove);
+ setItems(items);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXList.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,396 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.AbstractListModel;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JList;
+import javax.swing.ListModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class JAXXList extends JList {
+
+ private static final long serialVersionUID = 1L;
+
+ public class JAXXListModel extends AbstractListModel {
+
+ private List<Item> items;
+ private static final long serialVersionUID = -1598924187490122036L;
+
+ public JAXXListModel(List<Item> items) {
+ this.items = items;
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) {
+ Item item = (Item) e.getSource();
+ int itemIndex = JAXXListModel.this.items.indexOf(item);
+ int[] oldSelection = getSelectedIndices();
+ int[] newSelection;
+ int index = -1;
+ for (int i = 0; i < oldSelection.length; i++) {
+ if (oldSelection[i] == itemIndex) {
+ index = i;
+ break;
+ }
+ }
+ if (item.isSelected()) {
+ if (index != -1) // it was already selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length + 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, oldSelection.length);
+ newSelection[newSelection.length - 1] = itemIndex;
+ } else {
+ if (index == -1) // it already wasn't selected
+ {
+ return;
+ }
+ newSelection = new int[oldSelection.length - 1];
+ System.arraycopy(oldSelection, 0, newSelection, 0, index);
+ System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index);
+ }
+ setSelectedIndices(newSelection);
+ } else {
+ for (int i = 0; i < getSize(); i++) {
+ if (getElementAt(i) == ((Item) e.getSource()).getValue()) {
+ fireContentsChanged(JAXXListModel.this, i, i);
+ if (isSelectedIndex(i)) {
+ fireSelectionValueChanged(i, i, false);
+ }
+ return;
+ }
+ }
+ }
+ }
+ };
+ for (Item item : items) {
+ item.addPropertyChangeListener(listener);
+ }
+ }
+
+ public List<Item> getItems(){
+ return items;
+ }
+
+ @Override
+ public Object getElementAt(int i) {
+ return items.get(i).getValue();
+ }
+
+ @Override
+ public int getSize() {
+ return items.size();
+ }
+ }
+
+ public JAXXList() {
+ setCellRenderer(new DefaultListCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ ListModel model = list.getModel();
+ if (model instanceof JAXXListModel) {
+ Item item = ((JAXXListModel) model).items.get(index);
+ String label = item.getLabel();
+ if (label != null) {
+ value = label;
+ }
+ }
+ return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ }
+ });
+
+ addListSelectionListener(new ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ ListModel model = getModel();
+ if (model instanceof JAXXListModel) {
+ List<Item> items = ((JAXXListModel) model).items;
+ for (int i = items.size() - 1; i >= 0; i--) {
+ boolean selected = isSelectedIndex(i);
+ Item item = items.get(i);
+ if (selected != item.isSelected()) {
+ item.setSelected(selected);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ // this way we can keep it marked protected and still allow code in this file to call it
+ @Override
+ protected void fireSelectionValueChanged(int firstIndex, int lastIndex, boolean isAdjusting) {
+ super.fireSelectionValueChanged(firstIndex, lastIndex, isAdjusting);
+ }
+
+ public void setItems(List<Item> items) {
+ setModel(new JAXXListModel(items));
+ List<Integer> selectedIndexList = new ArrayList<Integer>();
+ for (int i = 0; i < items.size(); i++) {
+ if (items.get(i).isSelected()) {
+ selectedIndexList.add(i);
+ }
+ }
+ int[] selectedIndices = new int[selectedIndexList.size()];
+ for (int i = 0; i < selectedIndexList.size(); i++) {
+ selectedIndices[i] = selectedIndexList.get(i);
+ }
+ setSelectedIndices(selectedIndices);
+ }
+
+ public List<Item> getItems(){
+ if (getModel() instanceof JAXXListModel){
+ return ((JAXXListModel)getModel()).getItems();
+ }
+ return null;
+ }
+
+ public void setSelectedValue(Object value) {
+ super.setSelectedValue(value, true);
+ }
+
+ /**
+ * Set the selected Objects
+ *
+ * @param values Objects must be selected in the list
+ */
+ public void setSelectedValues(Object[] values) {
+ if (values != null){
+ List<Integer> selectedIndices = new ArrayList<Integer>();
+ ListModel model = getModel();
+ for (int i = 0; i < model.getSize(); i++) {
+ Object o = model.getElementAt(i);
+ for (Object value : values) {
+ if (o.equals(value)) {
+ selectedIndices.add(i);
+ break;
+ }
+ }
+ }
+ int[] ints = new int[selectedIndices.size()];
+ for (int i = 0; i < ints.length; i++) {
+ ints[i] = selectedIndices.get(i).intValue();
+ }
+ setSelectedIndices(ints);
+ }
+ else{
+ // No selection if values is null
+ setSelectedIndex(-1);
+ }
+ }
+
+ public void setSelectedItem(Item item) {
+ super.setSelectedValue(item.getValue(), true);
+ }
+
+ public void setSelectedItems(List<Item> itemsToSelect) {
+ if (itemsToSelect != null){
+ List<Item> items = getItems();
+ int[] indices = new int[itemsToSelect.size()];
+ int i = 0;
+ for (Item item : itemsToSelect){
+ indices[i] = items.indexOf(item);
+ i++;
+ }
+ super.setSelectedIndices(indices);
+ }
+ }
+
+ public Item getSelectedItem(){
+ Object selected = super.getSelectedValue();
+ return findItem(selected);
+ }
+
+ public List<Item> getSelectedItems(){
+ Object[] selected = super.getSelectedValues();
+ java.util.List<Item> itemsSelected = new ArrayList<Item>();
+ for (Object s : selected){
+ itemsSelected.add(findItem(s));
+ }
+ return itemsSelected;
+ }
+
+ public Item findItem(Object value){
+ List<Item> items = getItems();
+ if (items != null){
+ for (Item i : items){
+ if (i.getValue().equals(value)){
+ return i;
+ }
+ }
+ }
+ return null;
+ }
+
+ public void addItem(Item item){
+ List<Item> items = getItems();
+ if (items != null){
+ items.add(item);
+ setItems(items);
+ }
+ }
+
+ public void addAllItems(Collection<Item> itemsToAdd){
+ List<Item> items = getItems();
+ if (items != null){
+ items.addAll(itemsToAdd);
+ setItems(items);
+ }
+ }
+
+ public void removeItem(Item item){
+ List<Item> items = getItems();
+ if (items != null){
+ items.remove(item);
+ setItems(items);
+ }
+ }
+
+ public void removeAllItems(Collection<Item> itemsToRemove){
+ List<Item> items = getItems();
+ if (items != null){
+ items.removeAll(itemsToRemove);
+ setItems(items);
+ }
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param selects the objects to select in list after reflling his model
+ */
+ public void fillList(Collection<?> data, Collection<?> selects) {
+ if (selects == null) {
+ selects = java.util.Collections.EMPTY_LIST;
+ }
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = false;
+ for (Object select : selects) {
+ if (selected = o.equals(select)) {
+ break;
+ }
+ }
+ items.add(new Item(o.toString(), o.toString(), o, selected));
+ }
+ setItems(items);
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param select object to select in list after reflling his model
+ */
+ public void fillList(Collection<?> data, Object select) {
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = o.equals(select);
+ items.add(new Item(o.toString(), o.toString(), o, selected));
+ }
+ setItems(items);
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param select object to select in list after reflling his model
+ * @param methodName method to invoke to display data's name
+ */
+ public void fillList(Collection<?> data, Object select, String methodName) {
+ // prepare method to use
+ Method m = null;
+
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = o.equals(select);
+ if (m == null) {
+ try {
+ m = o.getClass().getMethod(methodName);
+ m.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("could not find method " + methodName + " on " + o.getClass());
+ }
+ }
+ try {
+ items.add(new Item(o.toString(), (String) m.invoke(o), o, selected));
+ } catch (SecurityException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ }
+ }
+ setItems(items);
+ }
+
+ /**
+ * Fill a list model with some datas, and select after all the given object
+ *
+ * @param data data ot inject in combo
+ * @param selects the objects to select in list after reflling his model
+ * @param methodName method to invoke to display data's name
+ */
+ public void fillList(Collection<?> data, Collection<?> selects, String methodName) {
+ // prepare method to use
+ Method m = null;
+
+ List<Item> items = new ArrayList<Item>();
+ for (Object o : data) {
+ boolean selected = selects.contains(o);
+ if (m == null) {
+ try {
+ m = o.getClass().getMethod(methodName);
+ m.setAccessible(true);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalArgumentException("could not find method " + methodName + " on " + o.getClass());
+ }
+ }
+ try {
+ items.add(new Item(o.toString(), (String) m.invoke(o), o, selected));
+ } catch (SecurityException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (IllegalArgumentException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ // shoudl never happen ?
+ throw new RuntimeException(e);
+ }
+ }
+ setItems(items);
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXList.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXTab.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,25 @@
+/*
+ * ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin,
+ * Tony Chemit
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##% */
+package jaxx.runtime.swing;
+
+/** @author chemit */
+public class JAXXTab extends Table {
+
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTab.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,92 @@
+package jaxx.runtime.swing;
+
+public class JAXXToggleButton extends javax.swing.JToggleButton {
+
+ private static final long serialVersionUID = 1L;
+ protected String glueText;
+ protected String normalText;
+ protected String glueTooltipText;
+ protected String normalTooltipText;
+ protected int normalMnemonic;
+ protected int glueMnemonic;
+ protected boolean _init;
+
+ public String getGlueText() {
+ return glueText;
+ }
+
+ public String getNormalText() {
+ return normalText;
+ }
+
+ public String getGlueTooltipText() {
+ return glueTooltipText;
+ }
+
+ public String getNormalTooltipText() {
+ return normalTooltipText;
+ }
+
+ public void setGlueText(String glueText) {
+ this.glueText = glueText;
+
+ }
+
+ public void setNormalText(String normalText) {
+ this.normalText = normalText;
+
+ }
+
+ public void setGlueTooltipText(String glueTooltipText) {
+ this.glueTooltipText = glueTooltipText;
+ }
+
+ public int getNormalMnemonic() {
+ return normalMnemonic;
+ }
+
+ public void setNormalMnemonic(int normalMnemonic) {
+ this.normalMnemonic = normalMnemonic;
+ }
+
+ public int getGlueMnemonic() {
+ return glueMnemonic;
+ }
+
+ public void setGlueMnemonic(int glueMnemonic) {
+ this.glueMnemonic = glueMnemonic;
+ }
+
+ public void setNormalTooltipText(String normalTooltipText) {
+ this.normalTooltipText = normalTooltipText;
+ if (!_init) {
+ init();
+ _init = true;
+ }
+ }
+
+ @Override
+ public void setSelected(boolean b) {
+ super.setSelected(b);
+ if (isSelected()) {
+ setText(getGlueText());
+ setToolTipText(getGlueTooltipText());
+ setMnemonic(getGlueMnemonic());
+ } else {
+ setText(getNormalText());
+ setToolTipText(getNormalTooltipText());
+ setMnemonic(getNormalMnemonic());
+ }
+ revalidate();
+ }
+
+ public void init() {
+ setSelected(false);
+ }
+
+ /* end raw body code */
+ public JAXXToggleButton() {
+ super();
+ _init = false;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXToggleButton.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXTree.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JTree;
+import javax.swing.event.TreeModelEvent;
+import javax.swing.event.TreeModelListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+public class JAXXTree extends JTree {
+
+ private static final long serialVersionUID = 1L;
+ private static final String SYNTHETIC = "<synthetic root node>";
+
+ public class JAXXTreeModel implements TreeModel {
+
+ private Item root;
+ private List<TreeModelListener> listeners = new ArrayList<TreeModelListener>();
+
+ public JAXXTreeModel(List<Item> items) {
+ if (items.size() == 1) {
+ this.root = items.get(0);
+ } else {
+ this.root = new Item(null, null, SYNTHETIC, false);
+ for (Item item : items) {
+ root.addChild(item);
+ }
+ }
+
+ PropertyChangeListener listener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(Item.SELECTED_PROPERTY)) {
+ Item item = (Item) e.getSource();
+ if (item.isSelected()) {
+ addSelectionPath(getTreePath(item));
+ } else {
+ removeSelectionPath(getTreePath(item));
+ }
+ } else {
+ Item item = (Item) e.getSource();
+ boolean root = item.getParent() == null;
+ TreePath path = !root ? getTreePath(item.getParent()) : null;
+ fireTreeNodesChanged(new TreeModelEvent(JAXXTreeModel.this, path,
+ !root ? new int[]{item.getParent().getChildren().indexOf(item)} : null,
+ new Object[]{item.getValue()}));
+ }
+ }
+ };
+ addPropertyChangeListener(root, listener);
+ }
+
+ private void addPropertyChangeListener(Item item, PropertyChangeListener listener) {
+ item.addPropertyChangeListener(listener);
+ List<Item> children = item.getChildren();
+ for (Item aChildren : children) {
+ addPropertyChangeListener(aChildren, listener);
+ }
+ }
+
+ @Override
+ public void addTreeModelListener(TreeModelListener listener) {
+ listeners.add(listener);
+ }
+
+
+ /* This is an inefficient implementation, but hand-coded tree structures are unlikely to contain
+ enough nodes for that to really matter. This could be sped up with caching. */
+ public Item findItem(Object value) {
+ return findItem(root, value);
+ }
+
+ private Item findItem(Item node, Object value) {
+ if (node.getValue() == value) {
+ return node;
+ } else {
+ List<Item> children = node.getChildren();
+ for (Item aChildren : children) {
+ Item result = findItem(aChildren, value);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+ }
+
+ private TreePath getTreePath(Item node) {
+ List<Object> path = new ArrayList<Object>();
+ while (node != null) {
+ path.add(0, node.getValue());
+ node = node.getParent();
+ }
+ return new TreePath(path.toArray());
+ }
+
+ @Override
+ public Object getChild(Object parent, int index) {
+ Item node = findItem(parent);
+ return node.getChildren().get(index).getValue();
+ }
+
+ @Override
+ public int getChildCount(Object parent) {
+ Item node = findItem(parent);
+ if (node == null){
+ return 0;
+ }
+ return node.getChildren().size();
+ }
+
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ Item node = findItem(parent);
+ List<Item> children = node.getChildren();
+ for (int i = 0, j = children.size(); i < j; i++) {
+ if (children.get(i).getValue() == child) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ @Override
+ public Object getRoot() {
+ return root.getValue();
+ }
+
+ public Item getRootItem() {
+ return root;
+ }
+
+ @Override
+ public boolean isLeaf(Object node) {
+ Item item = findItem(node);
+ return item != null && item.getChildren().size() == 0;
+ }
+
+ @Override
+ public void removeTreeModelListener(TreeModelListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void fireTreeNodesChanged(TreeModelEvent e) {
+ for (TreeModelListener listener : listeners) {
+ listener.treeNodesChanged(e);
+ }
+ }
+
+ @Override
+ public void valueForPathChanged(TreePath path, Object newValue) {
+ }
+ }
+
+ public JAXXTree(TreeModel model) {
+ super(model);
+ }
+
+ public JAXXTree() {
+ setCellRenderer(new DefaultTreeCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+ TreeModel model = tree.getModel();
+ if (model instanceof JAXXTreeModel) {
+ Item item = ((JAXXTreeModel) model).findItem(value);
+ if (item != null) {
+ String label = item.getLabel();
+ if (label != null) {
+ value = label;
+ }
+ }
+ }
+ return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+ });
+
+ addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ TreeModel model = getModel();
+ if (model instanceof JAXXTreeModel) {
+ scan((JAXXTreeModel) model, ((JAXXTreeModel) model).root);
+ }
+ }
+
+ private void scan(JAXXTreeModel model, Item item) {
+ TreePath path = model.getTreePath(item);
+ if (item.isSelected() != isPathSelected(path)) {
+ item.setSelected(!item.isSelected());
+ }
+ List<Item> children = item.getChildren();
+ for (Item aChildren : children) {
+ scan(model, aChildren);
+ }
+ }
+ });
+ }
+
+ public void setItem(Item items) {
+ List<Item> newItems = new ArrayList<Item>();
+ newItems.add(items);
+ setItems(newItems);
+ }
+
+ public void setItems(List<Item> items) {
+ // Create model
+ JAXXTreeModel model = new JAXXTreeModel(items);
+ if (model.getRoot() != null) {
+ setRootVisible(model.getRoot() != SYNTHETIC);
+ }
+ // Atach model
+ setModel(model);
+
+ // Appli selected items
+ if (items != null){
+ List<TreePath> treePathSelected = new ArrayList<TreePath>();
+ for (Item i : items){
+ if (i.isSelected()){
+ treePathSelected.add(model.getTreePath(i));
+ }
+ }
+ this.setSelectionPaths(convertToTreePathArray(treePathSelected.toArray()));
+ }
+ }
+
+ public Object getSelectionValue() {
+ TreePath selectionPath = getSelectionPath();
+ return selectionPath != null ? selectionPath.getLastPathComponent() : null;
+ }
+
+ public Item getRootItem(){
+ if (getModel() instanceof JAXXTreeModel){
+ return ((JAXXTreeModel)getModel()).getRootItem();
+ }
+ return null;
+ }
+
+ protected TreePath[] convertToTreePathArray(Object[] datas){
+ TreePath[] params = new TreePath[datas.length];
+ System.arraycopy(datas, 0, params, 0, datas.length);
+ return params;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JAXXTree.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,500 @@
+package jaxx.runtime.swing;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Vector;
+import javax.help.CSH;
+import javax.help.HelpBroker;
+import javax.help.HelpSet;
+import javax.swing.AbstractButton;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * La classe pour encapsuler l'aide de l'application.
+ *
+ * @param <B> le type de broker
+ * @author tony
+ * @since 1.4
+ */
+public abstract class JaxxHelpBroker<B extends JaxxHelpBroker<?>> {
+
+ public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
+ protected final String helpsetName;
+ protected final String defaultID;
+ protected final String helpKey;
+ // Main HelpSet & Broker
+ protected final HelpSet helpset;
+ protected final HelpBroker helpBroker;
+ protected Hashtable<Component, Cursor> cursors;
+ protected Cursor onItemCursor;
+ protected final Map<Component, String> cache;
+
+ protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
+ if (helpsetName == null) {
+ throw new NullPointerException("parameter helpsetName can not be null!");
+ }
+ this.helpsetName = helpsetName;
+ this.helpKey = helpKey;
+ this.defaultID = defaultID;
+ cache = new HashMap<Component, String>();
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, helpsetName);
+ helpset = new HelpSet(cl, url);
+ helpBroker = helpset.createHelpBroker();
+ } catch (Exception ee) {
+ throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+ }
+ }
+
+ public void prepareUI(JAXXObject c) {
+ if (c == null) {
+ throw new NullPointerException("parameter c can not be null!");
+ }
+
+ // l'ui doit avoir un boutton showHelp
+ AbstractButton help = getShowHelpButton(c);
+
+ if (help == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("no showButton detected for " + c.getClass());
+ }
+ } else {
+
+ // attach context to button
+ help.putClientProperty(JAXX_CONTEXT_ENTRY, c.getDelegateContext());
+
+ // add tracking action
+ ActionListener listener = getShowHelpAction();
+ if (log.isDebugEnabled()) {
+ log.debug("adding tracking action " + listener);
+ }
+ help.addActionListener(listener);
+
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("done for " + c);
+ }
+ }
+
+ public HelpBroker getHelpBroker() {
+ return helpBroker;
+ }
+
+ public String getHelpKey() {
+ return helpKey;
+ }
+
+ public HelpSet getHelpset() {
+ return helpset;
+ }
+
+ public String getHelpsetName() {
+ return helpsetName;
+ }
+
+ public String getDefaultID() {
+ return defaultID;
+ }
+
+ public void showHelpSet() {
+ if (log.isDebugEnabled()) {
+ log.debug(this);
+ }
+ new CSH.DisplayHelpFromSource(helpBroker);
+ }
+
+ public void showHelp(JAXXContext context, String helpId) {
+ }
+
+ public void installUI(Component comp, String helpId) {
+ CSH.setHelpIDString(comp, helpId);
+ if (log.isDebugEnabled()) {
+ log.debug(helpId + " : " + comp.getName());
+ }
+ cache.put(comp, helpId);
+ }
+
+ public class ShowHelpForTrackedComponentAction implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AbstractButton source = (AbstractButton) e.getSource();
+
+ JAXXContext context = (JAXXContext) source.getClientProperty(JAXX_CONTEXT_ENTRY);
+
+ // prepare cursor
+ onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor");
+ Vector<?> topComponents = null;
+ cursors = null;
+
+ if (onItemCursor != null) {
+ cursors = new Hashtable<Component, Cursor>();
+ topComponents = getTopContainers(source);
+ Enumeration<?> enums = topComponents.elements();
+ while (enums.hasMoreElements()) {
+ setAndStoreCursors((Container) enums.nextElement(), onItemCursor);
+ }
+ }
+
+ // get the tracked component
+ Component comp = null;
+ try {
+ MouseEvent event = getMouseEvent();
+ if (event == null) {
+ // tracking canceled
+ return;
+ }
+ comp = (Component) event.getSource();
+ if (log.isDebugEnabled()) {
+ log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY());
+ if (log.isDebugEnabled()) {
+ log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ } finally {
+ // restore the old cursors
+ if (topComponents != null) {
+ Enumeration<?> containers = topComponents.elements();
+ while (containers.hasMoreElements()) {
+ resetAndRestoreCursors((Container) containers.nextElement());
+ }
+ }
+ cursors = null;
+ }
+
+ String helpID = findHelpId(comp);
+ showHelp(context, helpID);
+ }
+
+ public String findHelpId(Component comp) {
+ String helpID = CSH.getHelpIDString(comp);
+ if (defaultID.equals(helpID)) {
+ String id = cache.get(comp);
+ // on verifie qu'on est bien sur sur le bon id
+ if (helpID.equals(id)) {
+ // ok
+ return helpID;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will try to find better id for comp : " + comp.getName());
+ }
+ // on est pas sur le bon id
+ // on recherche parmis les parents
+ helpID = findExtactHelpId(comp);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ return helpID;
+ }
+
+ protected String findExtactHelpId(Component comp) {
+ Container parent = comp.getParent();
+ while (parent != null) {
+ String id = cache.get(parent);
+ if (id == null) {
+ // ce container n'a pas d'id
+ // on va directement sur le parent
+ parent = parent.getParent();
+ continue;
+ }
+ // le parent possède un id
+ // on utilise cet id
+ return id;
+ }
+ // on a pas trouve d'id
+ // on retourne l'id par defaut
+ return defaultID;
+ }
+ }
+
+ protected AbstractButton getShowHelpButton(JAXXObject c) {
+ return (AbstractButton) c.getObjectById("showHelp");
+ }
+
+ protected ActionListener getShowHelpAction() {
+ return new ShowHelpForTrackedComponentAction();
+ }
+
+ //-------------------------------------------------------------------------
+ //--- Copy CSH code but with accessible modifiers and little improvments
+ //-------------------------------------------------------------------------
+ /*
+ * Get all top level containers to change it's cursors
+ */
+ protected Vector<?> getTopContainers(Object source) {
+ // This method is used to obtain all top level components of application
+ // for which the changing of cursor to question mark is wanted.
+ // Method Frame.getFrames() is used to get list of Frames and
+ // Frame.getOwnedWindows() method on elements of the list
+ // returns all Windows, Dialogs etc. It works correctly in application.
+ // Problem is in applets. There is no way how to get reference to applets
+ // from elsewhere than applet itself. So, if request for CSH (this means
+ // pressing help button or select help menu item) does't come from component
+ // in a Applet, cursor for applets is not changed to question mark. Only for
+ // Frames, Windows and Dialogs is cursor changed properly.
+
+ Vector<Component> containers = new Vector<Component>();
+ Component topComponent = null;
+ topComponent = getRoot(source);
+ if (topComponent instanceof Applet) {
+ try {
+ Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets();
+ while (applets.hasMoreElements()) {
+ containers.add(applets.nextElement());
+ }
+ } catch (NullPointerException npe) {
+ containers.add(topComponent);
+ }
+ }
+ Frame frames[] = Frame.getFrames();
+ for (int i = 0; i < frames.length; i++) {
+ Window[] windows = frames[i].getOwnedWindows();
+ for (int j = 0; j < windows.length; j++) {
+ containers.add(windows[j]);
+ }
+ if (!containers.contains(frames[i])) {
+ containers.add(frames[i]);
+ }
+ }
+ return containers;
+ }
+
+ protected Component getRoot(Object comp) {
+ Object parent = comp;
+ while (parent != null) {
+ comp = parent;
+ if (comp instanceof MenuComponent) {
+ parent = ((MenuComponent) comp).getParent();
+ } else if (comp instanceof Component) {
+ if (comp instanceof Window) {
+ break;
+ }
+ if (comp instanceof Applet) {
+ break;
+ }
+ parent = ((Component) comp).getParent();
+ } else {
+ break;
+ }
+ }
+ if (comp instanceof Component) {
+ return ((Component) comp);
+ }
+ return null;
+ }
+
+ /*
+ * Set the cursor for a component and its children.
+ * Store the old cursors for future resetting
+ */
+ protected void setAndStoreCursors(Component comp, Cursor cursor) {
+ if (comp == null) {
+ return;
+ }
+ Cursor compCursor = comp.getCursor();
+ if (compCursor != cursor) {
+ cursors.put(comp, compCursor);
+ log.debug("set cursor on " + comp);
+ comp.setCursor(cursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ setAndStoreCursors(component[i], cursor);
+ }
+ }
+ }
+
+ /*
+ * Actually restore the cursor for a component and its children
+ */
+ protected void resetAndRestoreCursors(Component comp) {
+ if (comp == null) {
+ return;
+ }
+ Cursor oldCursor = cursors.get(comp);
+ if (oldCursor != null) {
+ log.debug("restored cursor " + oldCursor + " on " + comp);
+ comp.setCursor(oldCursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ resetAndRestoreCursors(component[i]);
+ }
+ }
+ }
+
+ /**
+ * Context Sensitive Event Tracking
+ *
+ * Creates a new EventDispatchThread from which to dispatch events. This
+ * method returns when stopModal is invoked.
+ *
+ * @return MouseEvent The mouse event occurred. Null if
+ * cancelled on an undetermined object.
+ */
+ public static MouseEvent getMouseEvent() {
+ // Should the cursor change to a quesiton mark here or
+ // require the user to change the cursor externally to this method?
+ // The problem is that each component can have it's own cursor.
+ // For that reason it might be better to have the user change the
+ // cusor rather than us.
+
+ // To track context-sensitive events get the event queue and process
+ // the events the same way EventDispatchThread does. Filter out
+ // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???).
+ // Note: This code only handles mouse events. Accessiblity might
+ // require additional functionality or event trapping
+
+ // If the eventQueue can't be retrieved, the thread gets interrupted,
+ // or the thread isn't a instanceof EventDispatchThread then return
+ // a null as we won't be able to trap events.
+ try {
+ if (EventQueue.isDispatchThread()) {
+ EventQueue eq = null;
+
+ // Find the eventQueue. If we can't get to it then just return
+ // null since we won't be able to trap any events.
+
+ try {
+ eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ } catch (Exception ee) {
+ log.debug(ee);
+ }
+
+ // Safe guard
+ if (eq == null) {
+ return null;
+ }
+
+ int eventNumber = -1;
+
+ // Process the events until an object has been selected or
+ // the context-sensitive search has been canceled.
+ while (true) {
+ // This is essentially the body of EventDispatchThread
+ // modified to trap context-senstive events and act
+ // appropriately
+ eventNumber++;
+ AWTEvent event = eq.getNextEvent();
+ Object src = event.getSource();
+ // can't call eq.dispatchEvent
+ // so I pasted it's body here
+
+ if (log.isDebugEnabled()) {
+ log.debug(event);
+ }
+
+ // Not sure if I should suppress ActiveEvents or not
+ // Modal dialogs do. For now we will not suppress the
+ // ActiveEvent events
+
+ if (event instanceof ActiveEvent) {
+ ((ActiveEvent) event).dispatch();
+ continue;
+ }
+
+ if (src instanceof Component) {
+ // Trap the context-sensitive events here
+ if (event instanceof KeyEvent) {
+ KeyEvent e = (KeyEvent) event;
+ // if this is the cancel key then exit
+ // otherwise pass all other keys up
+ if (e.getKeyCode() == KeyEvent.VK_CANCEL ||
+ e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ e.consume();
+ return null;
+ } else {
+ e.consume();
+ // dispatchEvent(event);
+ }
+ } else if (event instanceof MouseEvent) {
+ MouseEvent e = (MouseEvent) event;
+ int eID = e.getID();
+
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isRightMouseButton(e)) {
+ // cancel tracking
+ e.consume();
+ if (log.isDebugEnabled()) {
+ log.debug("tracking canceled!!!");
+ }
+ return null;
+ }
+
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isLeftMouseButton(e)) {
+ if (eID == MouseEvent.MOUSE_CLICKED) {
+ if (eventNumber == 0) {
+ dispatchEvent(event);
+ continue;
+ }
+ }
+ e.consume();
+ return e;
+ } else {
+ e.consume();
+ }
+ } else {
+ dispatchEvent(event);
+ }
+ } else if (src instanceof MenuComponent) {
+ if (event instanceof InputEvent) {
+ ((InputEvent) event).consume();
+ }
+ } else {
+ log.error("unable to dispatch event: " + event);
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ if (log.isDebugEnabled()) {
+ log.debug(e);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Fall Through code");
+ }
+ return null;
+ }
+
+ private static void dispatchEvent(AWTEvent event) {
+ Object src = event.getSource();
+ if (event instanceof ActiveEvent) {
+ // This could become the sole method of dispatching in time.
+ ((ActiveEvent) event).dispatch();
+ } else if (src instanceof Component) {
+ ((Component) src).dispatchEvent(event);
+ } else if (src instanceof MenuComponent) {
+ ((MenuComponent) src).dispatchEvent(event);
+ } else {
+ log.error("unable to dispatch event: " + event);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,114 @@
+package jaxx.runtime.swing;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ */
+public class LocaleListCellRenderer extends DefaultListCellRenderer {
+
+ public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
+ private static final long serialVersionUID = 1L;
+ protected Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
+ protected boolean showIcon;
+ protected boolean showText;
+
+ public LocaleListCellRenderer() {
+ this(true, true);
+ }
+
+ public LocaleListCellRenderer(boolean showIcon, boolean showText) {
+ this.showIcon = showIcon;
+ this.showText = showText;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ Locale locale = (Locale) value;
+ if (locale != null) {
+ Icon icon = getIcon(locale);
+ comp.setIcon(icon);
+ }
+ String text = getText(locale);
+ String tip = getToolTipText(locale);
+ comp.setText(text);
+ comp.setToolTipText(tip);
+ return comp;
+ }
+
+ public String getText(Locale locale) {
+ String text = null;
+ if (showText) {
+ text = locale.getDisplayName(Locale.getDefault());
+ }
+ return text;
+ }
+
+ public String getToolTipText(Locale locale) {
+ String tip = locale.getDisplayName(Locale.getDefault());
+ return tip;
+ }
+
+ public boolean isShowText() {
+ return showText;
+ }
+
+ public boolean isShowIcon() {
+ return showIcon;
+ }
+
+ public void setShowIcon(boolean showIcon) {
+ boolean old = this.showIcon;
+ this.showIcon = showIcon;
+ firePropertyChange("showIcon", old, showIcon);
+ }
+
+ public void setShowText(boolean showText) {
+ boolean old = this.showText;
+ this.showText = showText;
+ firePropertyChange("showText", old, showText);
+ }
+
+ public synchronized Icon getIcon(Locale locale) {
+ if (!showIcon) {
+ return null;
+ }
+ Icon icon = cache.get(locale);
+ if (icon != null) {
+ return icon;
+ }
+
+ icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.toString());
+
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.toString());
+ if (locale.getCountry() != null) {
+ icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.getCountry().toLowerCase());
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
+
+ icon = SwingUtil.createActionIcon("i18n-" + locale.getCountry().toLowerCase());
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
+ }
+ }
+
+ }
+ }
+
+ cache.put(locale, icon);
+ return icon;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,104 @@
+package jaxx.runtime.swing;
+
+import org.nuiton.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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -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);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/OneClicListSelectionModel.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Spacer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JComponent;
+
+public class Spacer extends JComponent {
+
+ private static final long serialVersionUID = 1L;
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Spacer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/TabInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.Icon;
+import javax.swing.event.SwingPropertyChangeSupport;
+import java.awt.Color;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+public class TabInfo {
+
+ public static String BACKGROUND_PROPERTY = "background";
+ public static String DISABLED_ICON_PROPERTY = "disabledIcon";
+ public static String DISPLAYED_MNEMONIC_INDEX_PROPERTY = "displayedMnemonicIndex";
+ public static String ENABLED_PROPERTY = "enabled";
+ public static String FOREGROUND_PROPERTY = "foreground";
+ public static String ICON_PROPERTY = "icon";
+ public static String MNEMONIC_PROPERTY = "mnemonic";
+ public static String TITLE_PROPERTY = "title";
+ public static String TOOL_TIP_TEXT_PROPERTY = "toolTipText";
+ private String id;
+ private Color background;
+ private Icon disabledIcon;
+ private int displayedMnemonicIndex = -1;
+ private boolean enabled = true;
+ private Color foreground;
+ private Icon icon;
+ private int mnemonic = -1;
+ private String title;
+ private String toolTipText;
+ private PropertyChangeSupport propertyChangeSupport;
+
+ public TabInfo() {
+ }
+
+ public TabInfo(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Color getBackground() {
+ return background;
+ }
+
+ public void setBackground(Color background) {
+ Color oldValue = this.background;
+ this.background = background;
+ firePropertyChange(BACKGROUND_PROPERTY, oldValue, background);
+ }
+
+ public Icon getDisabledIcon() {
+ return disabledIcon;
+ }
+
+ public void setDisabledIcon(Icon disabledIcon) {
+ Icon oldValue = this.disabledIcon;
+ this.disabledIcon = disabledIcon;
+ firePropertyChange(DISABLED_ICON_PROPERTY, oldValue, disabledIcon);
+ }
+
+ public int getDisplayedMnemonicIndex() {
+ return displayedMnemonicIndex;
+ }
+
+ public void setDisplayedMnemonicIndex(int displayedMnemonicIndex) {
+ int oldValue = this.displayedMnemonicIndex;
+ this.displayedMnemonicIndex = displayedMnemonicIndex;
+ firePropertyChange(DISPLAYED_MNEMONIC_INDEX_PROPERTY, oldValue, displayedMnemonicIndex);
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ boolean oldValue = this.enabled;
+ this.enabled = enabled;
+ firePropertyChange(ENABLED_PROPERTY, oldValue, enabled);
+ }
+
+ public Color getForeground() {
+ return foreground;
+ }
+
+ public void setForeground(Color foreground) {
+ Color oldValue = this.foreground;
+ this.foreground = foreground;
+ firePropertyChange(FOREGROUND_PROPERTY, oldValue, foreground);
+ }
+
+ public Icon getIcon() {
+ return icon;
+ }
+
+ public void setIcon(Icon icon) {
+ Icon oldValue = this.icon;
+ this.icon = icon;
+ firePropertyChange(ICON_PROPERTY, oldValue, icon);
+ }
+
+ public int getMnemonic() {
+ return mnemonic;
+ }
+
+ public void setMnemonic(int mnemonic) {
+ int oldValue = this.mnemonic;
+ this.mnemonic = mnemonic;
+ firePropertyChange(MNEMONIC_PROPERTY, oldValue, mnemonic);
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ String oldValue = this.title;
+ this.title = title;
+ firePropertyChange(TITLE_PROPERTY, oldValue, title);
+ }
+
+ public String getToolTipText() {
+ return toolTipText;
+ }
+
+ public void setToolTipText(String toolTipText) {
+ String oldValue = this.toolTipText;
+ this.toolTipText = toolTipText;
+ firePropertyChange(TOOL_TIP_TEXT_PROPERTY, oldValue, toolTipText);
+ }
+
+ private PropertyChangeSupport getPropertyChangeSupport() {
+ if (propertyChangeSupport == null) {
+ propertyChangeSupport = new SwingPropertyChangeSupport(this);
+ }
+ return propertyChangeSupport;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().addPropertyChangeListener(property, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ getPropertyChangeSupport().removePropertyChangeListener(property, listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (propertyChangeSupport != null) {
+ getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+import java.awt.Color;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+public class TabInfoPropertyChangeListener implements PropertyChangeListener {
+
+ private JTabbedPane tabs;
+ private int tabIndex;
+
+ public TabInfoPropertyChangeListener(JTabbedPane tabs, int tabIndex) {
+ this.tabs = tabs;
+ this.tabIndex = tabIndex;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent e) {
+ String name = e.getPropertyName();
+ if (name.equals(TabInfo.TITLE_PROPERTY)) {
+ tabs.setTitleAt(tabIndex, (String) e.getNewValue());
+ } else if (name.equals(TabInfo.TOOL_TIP_TEXT_PROPERTY)) {
+ tabs.setToolTipTextAt(tabIndex, (String) e.getNewValue());
+ } else if (name.equals(TabInfo.FOREGROUND_PROPERTY)) {
+ tabs.setForegroundAt(tabIndex, (Color) e.getNewValue());
+ } else if (name.equals(TabInfo.BACKGROUND_PROPERTY)) {
+ tabs.setBackgroundAt(tabIndex, (Color) e.getNewValue());
+ } else if (name.equals(TabInfo.MNEMONIC_PROPERTY)) {
+ tabs.setMnemonicAt(tabIndex, (Integer) e.getNewValue());
+ } else if (name.equals(TabInfo.DISPLAYED_MNEMONIC_INDEX_PROPERTY)) {
+ tabs.setDisplayedMnemonicIndexAt(tabIndex, (Integer) e.getNewValue());
+ } else if (name.equals(TabInfo.ICON_PROPERTY)) {
+ tabs.setIconAt(tabIndex, (Icon) e.getNewValue());
+ } else if (name.equals(TabInfo.DISABLED_ICON_PROPERTY)) {
+ tabs.setDisabledIconAt(tabIndex, (Icon) e.getNewValue());
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Table.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Panel which uses a {@link GridBagLayout} by default.
+ *
+ * @author Ethan Nicholas
+ */
+public class Table extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3);
+ private GridBagConstraints tableConstraints = new GridBagConstraints();
+ private GridBagConstraints rowConstraints = null;
+ private GridBagConstraints cellConstraints = null;
+
+ public Table() {
+ super.setLayout(new GridBagLayout());
+
+ tableConstraints.insets = DEFAULT_INSETS;
+ }
+
+ @Override
+ public void setLayout(LayoutManager layout) {
+ // do nothing
+ }
+
+ public GridBagConstraints getTableConstraints() {
+ return tableConstraints;
+ }
+
+ public GridBagConstraints getRowConstraints() {
+ return rowConstraints;
+ }
+
+ public GridBagConstraints getCellConstraints() {
+ return cellConstraints;
+ }
+
+ public void newRow() {
+ tableConstraints.gridy++;
+ rowConstraints = (GridBagConstraints) tableConstraints.clone();
+ }
+
+ public void newCell() {
+ rowConstraints.gridx++;
+ cellConstraints = (GridBagConstraints) rowConstraints.clone();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Table.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/VBox.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import java.awt.Insets;
+
+/**
+ * Panel which uses a {@link VBoxLayout} by default.
+ *
+ * @author Ethan Nicholas
+ */
+public class VBox extends JPanel {
+
+ private static final long serialVersionUID = 1L;
+ public static final String SPACING_PROPERTY = "spacing";
+ public static final String MARGIN_PROPERTY = "margin";
+ public static final String HORIZONTAL_ALIGNMENT_PROPERTY = "horizontalAlignment";
+ public static final String VERTICAL_ALIGNMENT_PROPERTY = "verticalAlignment";
+ private Insets margin;
+
+ public VBox() {
+ super(new VBoxLayout());
+ }
+
+ /**
+ * Returns the spacing between components, in pixels. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @return spacing between components
+ */
+ public int getSpacing() {
+ return ((VBoxLayout) getLayout()).getSpacing();
+ }
+
+ /**
+ * Sets the spacing between components. Spacing is applied between components only,
+ * not to the top or bottom of the container.
+ *
+ * @param spacing new spacing value
+ */
+ public void setSpacing(int spacing) {
+ int oldValue = getSpacing();
+ ((VBoxLayout) getLayout()).setSpacing(spacing);
+ firePropertyChange(SPACING_PROPERTY, oldValue, spacing);
+ revalidate();
+ }
+
+ public int getHorizontalAlignment() {
+ return ((VBoxLayout) getLayout()).getHorizontalAlignment();
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ int oldValue = getHorizontalAlignment();
+ ((VBoxLayout) getLayout()).setHorizontalAlignment(horizontalAlignment);
+ firePropertyChange(HORIZONTAL_ALIGNMENT_PROPERTY, oldValue, horizontalAlignment);
+ revalidate();
+ }
+
+ public int getVerticalAlignment() {
+ return ((VBoxLayout) getLayout()).getVerticalAlignment();
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ int oldValue = getVerticalAlignment();
+ ((VBoxLayout) getLayout()).setVerticalAlignment(verticalAlignment);
+ firePropertyChange(VERTICAL_ALIGNMENT_PROPERTY, oldValue, verticalAlignment);
+ revalidate();
+ }
+
+ public Insets getMargin() {
+ return margin;
+ }
+
+ public void setMargin(Insets margin) {
+ Insets oldValue = this.margin;
+ this.margin = (Insets) margin.clone();
+ firePropertyChange(MARGIN_PROPERTY, oldValue, margin);
+ }
+
+ @Override
+ public Insets getInsets() {
+ Insets result = super.getInsets();
+ if (margin != null) {
+ result.top += margin.top;
+ result.left += margin.left;
+ result.right += margin.right;
+ result.bottom += margin.bottom;
+ }
+ return result;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBox.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/VBoxLayout.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.SwingConstants;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+
+/**
+ * Vertical box layout. The layout rules followed by this class are quite different than the core BoxLayout class,
+ * and in general represent a more useful algorithm.
+ *
+ * @author Ethan Nicholas
+ */
+public class VBoxLayout implements LayoutManager {
+
+ private int spacing = 6;
+ private int horizontalAlignment = SwingConstants.LEFT;
+ private int verticalAlignment = SwingConstants.TOP;
+
+ public int getSpacing() {
+ return spacing;
+ }
+
+ public void setSpacing(int spacing) {
+ this.spacing = spacing;
+ }
+
+ public int getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+
+ public void setHorizontalAlignment(int horizontalAlignment) {
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public int getVerticalAlignment() {
+ return verticalAlignment;
+ }
+
+ public void setVerticalAlignment(int verticalAlignment) {
+ this.verticalAlignment = verticalAlignment;
+ }
+
+ @Override
+ public void addLayoutComponent(String name, Component comp) {
+ }
+
+ @Override
+ public void layoutContainer(Container parent) {
+ Insets insets = parent.getInsets();
+ int parentWidth = parent.getSize().width - insets.left - insets.right;
+ int count = parent.getComponentCount();
+ Dimension preferredSize = parent.getPreferredSize();
+ int y;
+ switch (verticalAlignment) {
+ case SwingConstants.TOP:
+ y = insets.top;
+ break;
+ case SwingConstants.CENTER:
+ y = insets.top + (parent.getHeight() - preferredSize.height) / 2;
+ break;
+ case SwingConstants.BOTTOM:
+ y = insets.top + (parent.getHeight() - preferredSize.height);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid vertical alignment: " + verticalAlignment);
+ }
+
+ for (int i = 0; i < count; i++) {
+ Component component = parent.getComponent(i);
+ Dimension childPreferredSize = component.getPreferredSize();
+ int width = Math.min(childPreferredSize.width, parentWidth);
+ int x;
+ switch (horizontalAlignment) {
+ case SwingConstants.LEFT:
+ x = insets.left;
+ break;
+ case SwingConstants.CENTER:
+ x = insets.left + (parentWidth - childPreferredSize.width) / 2;
+ break;
+ case SwingConstants.RIGHT:
+ x = insets.left + (parentWidth - childPreferredSize.width);
+ break;
+ default:
+ throw new IllegalArgumentException("invalid horizontal alignment: " + horizontalAlignment);
+ }
+ component.setBounds(x, y, width, childPreferredSize.height);
+ y += childPreferredSize.height + spacing;
+ }
+ }
+
+ @Override
+ public Dimension minimumLayoutSize(Container parent) {
+ int width = 0;
+ int height = (parent.getComponentCount() - 1) * spacing;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension minimumSize = parent.getComponent(i).getMinimumSize();
+ width = Math.max(width, minimumSize.width);
+ height += minimumSize.height;
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public Dimension preferredLayoutSize(Container parent) {
+ int width = 0;
+ int height = (parent.getComponentCount() - 1) * spacing;
+ for (int i = parent.getComponentCount() - 1; i >= 0; i--) {
+ Dimension preferredSize = parent.getComponent(i).getPreferredSize();
+ width = Math.max(width, preferredSize.width);
+ height += preferredSize.height;
+ }
+ Insets insets = parent.getInsets();
+ return new Dimension(width + insets.left + insets.right, height + insets.top + insets.bottom);
+ }
+
+ @Override
+ public void removeLayoutComponent(Component comp) {
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxLayout.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,119 @@
+/*
+* *##% ui
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor;
+
+import org.apache.commons.beanutils.Converter;
+import org.nuiton.util.ConverterUtil;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.event.CellEditorListener;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import java.util.EventObject;
+
+/**
+ * A class cell editor (fork from comandline project).
+ *
+ * @author chemit
+ */
+public class ClassCellEditor implements TableCellEditor {
+
+ protected TableCellEditor delegate;
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+
+ String valStr = (value + "").trim();
+ if (valStr.equals("null")) {
+ valStr = "";
+ } else if (valStr.startsWith("class ")) {
+ valStr = valStr.substring(6);
+ }
+ Component comp;
+ comp = getDelegate().getTableCellEditorComponent(table, valStr, isSelected, row, column);
+ return comp;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ Object o = !hasDelegate() ? null : delegate.getCellEditorValue();
+ if (o == null) {
+ return null;
+ }
+ Converter converter = ConverterUtil.getConverter(Class.class);
+
+ try {
+ if (converter != null) {
+ return converter.convert(Class.class, o);
+ }
+ o = Class.forName(o + "");
+ } catch (Exception e) {
+ o = null;
+ }
+ return o;
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject anEvent) {
+ return !hasDelegate() || delegate.isCellEditable(anEvent);
+ }
+
+ @Override
+ public boolean shouldSelectCell(EventObject anEvent) {
+ return hasDelegate() && delegate.shouldSelectCell(anEvent);
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ return !hasDelegate() || delegate.stopCellEditing();
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ if (hasDelegate()) {
+ delegate.cancelCellEditing();
+ }
+ }
+
+ @Override
+ public void addCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.addCellEditorListener(l);
+ }
+ }
+
+ @Override
+ public void removeCellEditorListener(CellEditorListener l) {
+ if (hasDelegate()) {
+ delegate.removeCellEditorListener(l);
+ }
+ }
+
+ protected TableCellEditor getDelegate() {
+ if (delegate == null) {
+ delegate = new DefaultCellEditor(new JTextField());
+ }
+ return delegate;
+ }
+
+ protected boolean hasDelegate() {
+ return delegate != null;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/ClassCellEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,57 @@
+/*
+ * *##% Lutin utilities library
+ * Copyright (C) 2004 - 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor;
+
+import javax.swing.JComboBox;
+import java.util.EnumSet;
+import org.nuiton.util.ReflectUtil;
+
+/**
+ * Une éditeur d'enum.
+ *
+ * @param <E> le type d'enumeration a editer.
+ *
+ * @author chemit
+ *
+ * @since 1.6.0
+ */
+public class EnumEditor<E extends Enum<E>> extends JComboBox {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = 2693771553067104538L;
+ protected Class<E> type;
+
+ public static <E extends Enum<E>> EnumEditor<E> newEditor(Class<E> type) {
+ return new EnumEditor<E>(type);
+ }
+
+ public EnumEditor(Class<E> type) {
+ super(buildModel(type));
+ }
+
+ @Override
+ public E getSelectedItem() {
+ return (E) super.getSelectedItem();
+ }
+
+ protected static <E extends Enum<E>> Object[] buildModel(Class<E> type) {
+ Class<E> enumClass = ReflectUtil.getEnumClass(type);
+ EnumSet<E> result = EnumSet.allOf(enumClass);
+ return result.toArray(new Object[result.size()]);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/EnumEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,64 @@
+/*
+* *##% Lutin utilities library
+ * Copyright (C) 2004 - 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+package jaxx.runtime.swing.editor;
+
+import javax.swing.JComboBox;
+import java.util.Locale;
+import org.nuiton.i18n.I18n;
+
+/**
+ * A {@link Locale} editor.
+ * <p/>
+ * use the static method to have an instance of editor {@link #newEditor(java.util.Locale[])}
+ * <p/>
+ * If no locale is given to this method, it will go and seek via
+ * {@link org.nuiton.i18n.I18nLoader#getLocales()} all loaded locales in i18n system
+ *
+ * @author chemit
+ * @since 1.6.0
+ */
+public class LocaleEditor extends JComboBox {
+
+ /** serialVersionUID */
+ private static final long serialVersionUID = -6777873426011538807L;
+
+ protected Locale[] type;
+
+ public static LocaleEditor newEditor(Locale... type) {
+ return new LocaleEditor(type);
+ }
+
+ public LocaleEditor(Locale... type) {
+ super(buildModel(type));
+ }
+
+ @Override
+ public Locale getSelectedItem() {
+ return (Locale) super.getSelectedItem();
+ }
+
+ protected static Locale[] buildModel(Locale... type) {
+ if (type.length > 0) {
+ return type;
+ }
+ // get availables locales registred in I18n system
+ type = I18n.getLoader().getLocales();
+ return type;
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/LocaleEditor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,59 @@
+package jaxx.runtime.swing.navigation;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import javax.swing.JPanel;
+import jaxx.runtime.swing.Item;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author letellier
+ * @since 1.7.2
+ */
+public class ItemNavigationCardPanel extends JPanel {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(ItemNavigationCardPanel.class);
+ private static final long serialVersionUID = 1L;
+ CardLayout layout;
+
+ public ItemNavigationCardPanel() {
+ super();
+
+ layout = new CardLayout();
+ setLayout(layout);
+ }
+
+ public void showItem(Item i) {
+ if (i != null && i.getValue() != null) {
+ if (i.getValue() instanceof Class<?>) {
+ layout.show(this, i.getValue().getClass().getName());
+ } else {
+ layout.show(this, i.getValue().getClass().getName());
+ }
+ }
+ }
+
+ public Component getShowedComponent() {
+ Component[] components = getComponents();
+ if (components != null) {
+ for (Component c : components) {
+ if (c.isVisible()) {
+ return c;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Component add(Component comp) {
+ if (!(comp instanceof ItemNavigationPanel)) {
+ throw new IllegalArgumentException("ItemNavigationCardPanel must be have only ItemNavigationPanel children");
+ }
+ super.add(comp, ((ItemNavigationPanel) comp).getAssociatedClass().getName());
+ return comp;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationCardPanel.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,28 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author letellier
+ */
+public class ItemNavigationPanel extends JPanel{
+
+ private static final long serialVersionUID = 1L;
+
+ protected Class associatedClass = null;
+
+ public ItemNavigationPanel(Class associatedClass) {
+ this.associatedClass = associatedClass;
+ }
+
+ public Class getAssociatedClass() {
+ return associatedClass;
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemNavigationPanel.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,64 @@
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.TreeModel;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.runtime.swing.JAXXTree.JAXXTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** A {@link javax.swing.event.TreeSelectionListener} implementation@@author letellier */
+public abstract class ItemTreeNavigationAdapter implements TreeSelectionListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(ItemTreeNavigationAdapter.class);
+
+ /** l'ui contenant l'arbre de navigation */
+ protected JAXXObject context;
+
+ protected JAXXTree tree;
+ protected ItemNavigationCardPanel cardPanel;
+
+ public ItemTreeNavigationAdapter(JAXXObject context, JAXXTree tree, ItemNavigationCardPanel cardPanel) {
+ super();
+ this.context = context;
+ this.tree = tree;
+ this.cardPanel = cardPanel;
+
+ // Attache ce listener a l'arbre de navigation
+ tree.addTreeSelectionListener(this);
+ }
+
+ @Override
+ public void valueChanged(TreeSelectionEvent e) {
+ log.debug("Selection in JAXXTree changed" + e.getPath());
+
+ // Recuperation du path selectionne
+ TreePath path = e.getNewLeadSelectionPath();
+ TreeModel model = tree.getModel();
+
+ if (!(model instanceof JAXXTreeModel)){
+ log.error("Its not an JAXXTreeModel");
+ return;
+ }
+ // Find item coresponding
+ Item itemSelected = ((JAXXTreeModel) model).findItem(path.getLastPathComponent());
+
+ // Show corresponding panel
+ cardPanel.showItem(itemSelected);
+
+ // Notifie change
+ valueChanged(itemSelected.getValue());
+ }
+
+ /**
+ * Method abstraite pour pouvoir propager la donnee selectionner
+ *
+ * @param data value of the node selected
+ */
+ protected abstract void valueChanged(Object data);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/ItemTreeNavigationAdapter.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,244 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.List;
+
+/**
+ * Un modèle de wizard.
+ *
+ *
+ * <b>Note:</b> le type des étapes doit être uné énumération qui implante
+ * {@link WizardStep}.
+ *
+ * @param <E> le type des étapes.
+ *
+ * @author tony
+ * @since 1.3
+ * @see WizardStep
+ */
+public class WizardModel<E extends WizardStep> {
+
+ public static final String STEPS_PROPERTY_NAME = "steps";
+ public static final String STEP_PROPERTY_NAME = "step";
+ public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
+ public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
+ public static final String VALID_STEP_PROPERTY_NAME = "validStep";
+ /**
+ * le type d'une etape du model (doit etre une enumeration)
+ */
+ protected final Class<E> stepClass;
+ /**
+ * Toutes les étapes à passer
+ */
+ protected List<E> steps;
+ /** les etapes a exclure */
+ protected List<E> excludeSteps;
+ /**
+ * L'étape courante
+ */
+ protected E step;
+ /**
+ * drapeau pour valider l'état de l'étape courante
+ */
+ protected boolean validStep;
+ /**
+ * drapeau lorsque le modele effectue des operations
+ * de transformation de modele mais que les écouteurs
+ * ne devraient pas tenir compte des modifications
+ */
+ protected boolean valueAdjusting;
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+
+ public WizardModel(Class<E> stepClass, E... steps) {
+ if (!Enum.class.isAssignableFrom(stepClass)) {
+ throw new IllegalArgumentException("stepClass must be an Enumeration but was " + stepClass.getName());
+ }
+ this.stepClass = stepClass;
+ this.pcs = new PropertyChangeSupport(this);
+ this.steps = new java.util.ArrayList<E>();
+ if (steps.length > 0) {
+ setSteps(steps);
+ }
+ }
+
+ public void start() {
+ if (steps.isEmpty()) {
+ throw new IllegalStateException("can not start, no step found");
+ }
+ step = null;
+ E startStep = steps.get(0);
+ setStep(startStep);
+ }
+
+ public void gotoNextStep() {
+ E nextStep = getNextStep();
+ if (nextStep == null) {
+ throw new IllegalStateException("no next step to go");
+ }
+ setStep(nextStep);
+ }
+
+ public void gotoPreviousStep() {
+ E previousStep = getPreviousStep();
+ if (previousStep == null) {
+ throw new IllegalStateException("no previous step to go");
+ }
+ setStep(previousStep);
+ }
+
+ public void gotoStep(E e) {
+ if (e == null) {
+ throw new NullPointerException("step can not be null");
+ }
+ if (!steps.contains(e)) {
+ throw new IllegalStateException("step " + e.toString() + " is not in universe of steps (" + steps + ")");
+ }
+ setStep(e);
+ }
+
+ public E getStep() {
+ return step;
+ }
+
+ public int getStepIndex(E s) {
+ int index = steps.indexOf(s);
+ return index;
+ }
+
+ public boolean isValidStep() {
+ return validStep;
+ }
+
+ public E getPreviousStep() {
+ E e = getPreviousStep(step);
+ return e;
+ }
+
+ public E getPreviousStep(E step) {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
+ public E getNextStep(E step) {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
+ public E getNextStep() {
+ int index = getStepIndex(step);
+ if (index == -1 || index == steps.size() - 1) {
+ // si pas de step positionne ou dernier etape
+ return null;
+ }
+ return steps.get(index + 1);
+ }
+
+ public java.util.List<E> getSteps() {
+ return steps;
+ }
+
+ public boolean isValueAdjusting() {
+ return valueAdjusting;
+ }
+
+ /**
+ * Change l'univers des etapes.
+ *
+ * Note: on presume ici que l'étape courante est toujours la meme.
+ *
+ * @param steps le nouvel univers des etapes
+ */
+ public void setSteps(E... steps) {
+ java.util.List<E> oldValue = this.steps;
+ this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
+ firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ }
+
+ public void setValueAdjusting(boolean valueAdjusting) {
+ this.valueAdjusting = valueAdjusting;
+ }
+
+ public void setExcludeSteps(List<E> excludeSteps) {
+ this.excludeSteps = excludeSteps;
+ }
+ public boolean validate(E s) {
+ return step != null;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+
+ public void validate() {
+ if (step == null) {
+ // pas de validation quand aucune etape n'est sélectionnée
+ return;
+ }
+ boolean validate = validate(step);
+ this.validStep = validate;
+ // toujours forcer la propagation
+ firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
+ }
+
+ protected Class<E> getStepClass() {
+ return stepClass;
+ }
+
+ protected void setStep(E step) {
+ E oldValue = this.step;
+ this.step = step;
+ firePropertyChange(STEP_PROPERTY_NAME, oldValue, step);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ // la propriete previousStep peut avoir changee
+ firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null, getPreviousStep());
+ validate();
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) {
+ pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
+ }
+
+ protected E[] updateStepUniverse() {
+ return null;
+ }
+
+ protected void updateUniverse() {
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,108 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.SwingWorker;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * La classe de base a implanter pour definir l'action d'une operation
+ * dans un wizard.
+ *
+ * @author tony
+ * @param <E> le type d'étapes
+ * @param <M> le type de modèle
+ * @since 1.3
+ */
+public abstract class WizardOperationAction<E extends WizardOperationStep, M extends WizardOperationModel<E>> extends SwingWorker<WizardOperationState, String> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardOperationAction.class);
+ E operation;
+ WizardOperationState operationState;
+ Exception error;
+
+ public WizardOperationAction(E operation) {
+ super();
+ if (!operation.isOperation()) {
+ throw new IllegalArgumentException("the step " + operation + " has no operation defined");
+ }
+ this.operation = operation;
+ }
+
+ public E getOperation() {
+ return operation;
+ }
+
+ public Exception getError() {
+ return error;
+ }
+
+ public void setError(Exception e) {
+ error = e;
+ }
+
+ public void sendMessage(String msg) {
+ firePropertyChange("message", null, msg);
+ }
+
+ public abstract void start(JAXXContext context);
+
+ public abstract void beforeAction(JAXXContext context, M model) throws Exception;
+
+ public abstract WizardOperationState doAction(M model) throws Exception;
+
+ public abstract WizardOperationState onError(M model, Exception e);
+
+ public abstract WizardOperationState onCancel(M model, Exception e);
+
+ protected abstract M getModel();
+
+ public WizardOperationState getOperationState() {
+ return operationState;
+ }
+
+ protected abstract JAXXContext getContext();
+
+ @Override
+ public String toString() {
+ return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
+ }
+
+ @Override
+ protected WizardOperationState doInBackground() throws Exception {
+ log.trace(this);
+ WizardOperationState result;
+ M model = getModel();
+ try {
+ beforeAction(getContext(), model);
+ result = doAction(model);
+ } catch (Exception e) {
+ error = e;
+ result = onError(model, e);
+ }
+ return result;
+ }
+
+ @Override
+ protected void done() {
+ log.trace(this);
+ WizardOperationState result = null;
+ try {
+ if (isCancelled()) {
+
+ result = onCancel(getModel(), error);
+ } else {
+ result = get();
+ }
+ } catch (Exception e) {
+ result = WizardOperationState.FAILED;
+ error = e;
+ // ne devrait jamais arrivé ?
+ log.error(e.getMessage(), e);
+ } finally {
+ // on enregistre le resultat de l'opération
+ this.operationState = result;
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,204 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import javax.swing.SwingWorker.StateValue;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Thread qui réalise les opérations.
+ *
+ * Pour exécuter une nouvelle opération, on utilise la méthode
+ * {@link #launchOperation(SynchroActionWorker)}.
+ *
+ * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
+ *
+ * @param <E> le type des etapes
+ * @param <M> le type de modele
+ * @param <A> le type d'action d'operation
+ *
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardOperationActionThread<E extends WizardOperationStep, M extends WizardOperationModel<E>, A extends WizardOperationAction<E, M>> extends Thread implements PropertyChangeListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardOperationActionThread.class);
+ /**
+ * l'état du thread si annulé
+ */
+ private boolean canceled;
+ protected Class<M> modelClass;
+ protected A currentAction;
+ /**
+ * un lock pour permettre la suspension et la reprise du thread
+ * lors du mode interactif.
+ */
+ private final Object LOCK = new Object();
+
+ protected abstract M getModel();
+
+ protected abstract JAXXContext getContext();
+
+ public WizardOperationActionThread(Class<M> modelClass) throws IllegalArgumentException {
+ super(WizardOperationActionThread.class.getSimpleName() + " " + new Date());
+ this.modelClass = modelClass;
+ }
+
+ public void cancel() {
+ log.info("cancel " + this);
+ this.canceled = true;
+
+ // on annule le modele
+ getModel().cancel();
+
+ // on rend la main au thread
+ setWaiting(false);
+ }
+
+ @SuppressWarnings("unchecked")
+ public A launchOperation(E operation) {
+
+ if (currentAction != null && (!currentAction.isDone() || currentAction.operationState == WizardOperationState.RUNNING)) {
+ // on ne peut traiter qu'une seule opération à la fois
+ throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
+ }
+ currentAction = (A) getModel().getOperationAction(operation);
+
+ // on libere le thread pour qu'il execute l'opération
+ setWaiting(false);
+
+ return currentAction;
+ }
+
+ public A getCurrentAction() {
+ return currentAction;
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ if ("state".equals(evt.getPropertyName())) {
+ StateValue state = (StateValue) evt.getNewValue();
+ if (state == StateValue.DONE) {
+ // on rend la main au thread pour qu'il attende une prochaine operation
+ setWaiting(false);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ // on vérifie que le context contient bien le modèle
+ if (getModel() == null) {
+ throw new NullPointerException("could not find model " + modelClass + " for " + this);
+ }
+
+ while (!canceled) {
+
+ if (canceled) {
+ // une annulation a été demandé
+ // donc même si une opération est demandée, on ne la traite
+ // pas
+ break;
+ }
+
+ // en attente qu'une opération
+ // le block est bloqué jusqu'à arrivée d'une opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread a repris la main, donc plus en attente
+ log.trace("no more waiting " + this);
+
+ if (!canceled) {
+ // une opération a été demandée
+
+ // le thread écoute les modifications de l'action
+ currentAction.addPropertyChangeListener(this);
+
+ // l'opération passe en etant en cours
+ getModel().setOperationState(WizardOperationState.RUNNING);
+
+ // démarrage de l'opération dans un worker
+ currentAction.start(getContext());
+ // le thread est bloqué jusqu'à la fin de l'opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread reprend la main des que l'operation
+ // est terminée ou a été annulée, on passera alors
+ // dans la méthode onPropertyChanged
+
+ if (canceled) {
+ getModel().setOperationState(WizardOperationState.CANCELED);
+ } else {
+ getModel().setOperationState(currentAction.getOperationState());
+ }
+
+ // le thread n'écoute plus l'action car elle est terminée
+ // ou annulée
+ currentAction.removePropertyChangeListener(this);
+ // suppression de l'action
+ //currentAction = null;
+ }
+
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ unlockThread();
+ log.trace(this + " will close...");
+ close();
+ }
+ }
+
+ /**
+ * La méthode pour nettoyer le thread, a la fermeture.
+ *
+ */
+ protected void close() {
+ // par defaut, on ne fait rien
+ log.trace(this);
+ }
+
+ protected void setWaiting(boolean waiting) {
+
+ if (waiting && !canceled) {
+ // locking thread
+ try {
+ lockThread();
+ } catch (InterruptedException ex) {
+ log.error(ex.getMessage(), ex);
+ canceled = true;
+ }
+ }
+
+ if (!waiting) {
+ // release lock
+ unlockThread();
+ }
+ }
+
+ protected void lockThread() throws InterruptedException {
+ synchronized (LOCK) {
+ log.trace(this);
+ // lock
+ LOCK.wait();
+ }
+ }
+
+ protected void unlockThread() {
+ synchronized (LOCK) {
+ log.trace(this);
+ // unlock
+ LOCK.notify();
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,269 @@
+package jaxx.runtime.swing.wizard;
+
+import java.util.Arrays;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.swing.SwingWorker.StateValue;
+
+/**
+ * Un modèle de wizard avec des opérations.
+ *
+ * @param <E> le type des étapes.
+ * @author tony
+ * @since 1.3
+ */
+public class WizardOperationModel<E extends WizardOperationStep> extends WizardModel<E> {
+
+ public static final String OPERATIONS_PROPERTY_NAME = "operations";
+ public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
+ public static final String MODEL_STATE_PROPERTY_NAME = "modelState";
+ public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted";
+
+ /**
+ * La liste des opérations à effectuer
+ */
+ protected Set<E> operations;
+ /**
+ * Pour conserver les états des opérations
+ */
+ protected Map<E, WizardOperationState> operationStates;
+ protected Map<E, WizardOperationAction> operationActions;
+ /**
+ * L'état générale du modèle
+ */
+ protected WizardOperationState modelState;
+ /**
+ * un drapeau pour savoir siune opération a été lancée
+ */
+ protected boolean wasStarted;
+
+ @SuppressWarnings("unchecked")
+ public <T extends Enum<T>> WizardOperationModel(Class<E> stepClass, E... steps) {
+ super(stepClass, steps);
+ Class<T> k = (Class) stepClass;
+ this.operationStates = (Map) new EnumMap(k);
+ this.operations = (Set<E>) EnumSet.noneOf(k);
+ this.operationActions = (Map) new EnumMap(k);
+ }
+
+ public Set<E> getOperations() {
+ return operations;
+ }
+
+ public WizardOperationState getModelState() {
+ return modelState;
+ }
+
+ public boolean isWasStarted() {
+ return wasStarted;
+ }
+
+ @SuppressWarnings("unchecked")
+ public E getOperation() {
+ return getStep() != null && getStep().isOperation() ? getStep() : null;
+ }
+
+ public WizardOperationState getOperationState() {
+ E operation = getOperation();
+ return getOperationState(operation);
+ }
+
+ public WizardOperationState getOperationState(E operation) {
+ return operationStates.get(operation);
+ }
+
+ public WizardOperationAction getOperationAction(E operation) {
+ WizardOperationAction action = operationActions.get(operation);
+ if (action == null) {
+ try {
+ action = operation.getActionClass().newInstance();
+ operationActions.put(operation, action);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ return action;
+ }
+
+ public void setOperationState(WizardOperationState operationState) {
+ E operation = getOperation();
+ setOperationState(operation, operationState);
+ }
+
+ public void setOperationState(E operation, WizardOperationState operationState) {
+ WizardOperationState oldValue = getOperationState(operation);
+ this.operationStates.put(operation, operationState);
+ fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getSteps().indexOf(operation), oldValue, operationState);
+ updateModelState(operation, operationState);
+ validate();
+ }
+
+ public boolean[] getAccessibleSteps() {
+ boolean[] result = new boolean[getSteps().size()];
+ int index = getSteps().indexOf(getStep());
+ if (index != -1) {
+
+ for (int i = 0, j = steps.size(); i < j; i++) {
+ if (i <= index) {
+ // tous les onglets inferieur ou egal au courant sont accessibles
+ result[i] = true;
+ continue;
+ }
+ // les onglets au dela de l'onglet sélectionné sont accessibles
+ // uniquement si l'onglet precedent est accessible, valide et son etat est a SUCCESSED
+ E previousStep = steps.get(i - 1);
+ result[i] = modelState == WizardOperationState.SUCCESSED ||
+ (result[i - 1] &&
+ validate(previousStep) &&
+ (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED));
+ }
+ }
+ //System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
+ return result;
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ updateUniverse();
+ //setSteps(steps.toArray((E[]) Array.newInstance(stepClass, steps.size())));
+
+ // le modèle n'est pas démarré
+ setModelState(WizardOperationState.PENDING);
+ }
+
+ public void cancel() {
+
+ for (E op : operations) {
+ if (getOperationState(op) == WizardOperationState.PENDING) {
+ // on annule l'opération à venir
+ setOperationState(op, WizardOperationState.CANCELED);
+ }
+ }
+ setModelState(WizardOperationState.CANCELED);
+ if (getStep() != null && getStep().isOperation()) {
+ WizardOperationAction action = getOperationAction(getStep());
+ if (action != null) {
+ if (!action.isCancelled() && !action.isDone() && action.getState() == StateValue.STARTED) {
+ System.out.println("cancel action " + action);
+ // on annule l'action
+ action.cancel(true);
+ }
+ }
+ }
+ }
+
+ public WizardOperationModel<E> addOperation(E operation) {
+ operations.add(operation);
+ // mis a jour de l'univers des etapes et operations
+ updateUniverse();
+ // validation
+ validate();
+ return this;
+ }
+
+ public void removeOperation(E operation) {
+ operations.remove(operation);
+
+ // mis a jour de l'univers des etapes et operations
+ updateUniverse();
+ // validation
+ validate();
+ }
+
+ @Override
+ public void setSteps(E... steps) {
+ super.setSteps(steps);
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ updateOperationStates(Arrays.asList(steps));
+ }
+
+ public void updateOperationStates(List<E> steps) {
+ int index = 0;
+ for (E e : steps) {
+ fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, index++, null, getOperationState(e));
+ }
+ firePropertyChange(MODEL_STATE_PROPERTY_NAME, null, modelState);
+ }
+
+ public WizardOperationAction reloadOperation(E operation) {
+ operationActions.remove(operation);
+ WizardOperationAction newOp = getOperationAction(operation);
+ return newOp;
+ }
+
+ protected void setModelState(WizardOperationState modelState) {
+ WizardOperationState oldValue = this.modelState;
+ this.modelState = modelState;
+ firePropertyChange(MODEL_STATE_PROPERTY_NAME, oldValue, modelState);
+ if (!wasStarted) {
+ if ((oldValue == null || oldValue == WizardOperationState.PENDING) && modelState == WizardOperationState.RUNNING) {
+ this.wasStarted = true;
+ firePropertyChange(WAS_STARTED_PROPERTY_NAME, false, true);
+ }
+ }
+ }
+
+ protected void updateModelState(E operation, WizardOperationState operationState) {
+
+ switch (operationState) {
+ case RUNNING:
+ //le modele est occupé
+ setModelState(WizardOperationState.RUNNING);
+ break;
+ case FAILED:
+ //le modele est en erreur
+ setModelState(WizardOperationState.FAILED);
+ break;
+ case CANCELED:
+ //le modele devient annulé
+ setModelState(WizardOperationState.CANCELED);
+ return;
+ case PENDING:
+ //le modele est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case NEED_FIX:
+ //le modele est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case SUCCESSED:
+ // on regarde si on peut passer le model a l'état success
+ boolean valid = true;
+ for (E o : operations) {
+ if (getOperationState(o) != WizardOperationState.SUCCESSED) {
+ valid = false;
+ break;
+ }
+ }
+ if (valid) {
+ setModelState(WizardOperationState.SUCCESSED);
+ } else {
+ setModelState(WizardOperationState.PENDING);
+ }
+ break;
+ }
+ updateOperationStates(steps);
+ }
+
+ @Override
+ protected void updateUniverse() {
+ E[] newSteps = updateStepUniverse();
+ setSteps(newSteps);
+ }
+
+ protected int getOperationIndex(E operation) {
+ int index = 0;
+ for (E o : operations) {
+ if (operation == o) {
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,32 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ * Pour caractériser l'état d'une opération.
+ */
+public enum WizardOperationState {
+
+ /**
+ * quand l'opération n'a pas encore été réalisée
+ */
+ PENDING,
+ /**
+ * quand l'opération est en cours
+ */
+ RUNNING,
+ /**
+ * quand l'opération est annulé en cours d'exécution
+ */
+ CANCELED,
+ /**
+ * quand une erreur s'est produite pendant l'exécution
+ */
+ FAILED,
+ /**
+ * quand l'exécution s'est terminée mais requière des corrections
+ */
+ NEED_FIX,
+ /**
+ * quand l'exécution s'est terminée et ne requière pas de correction
+ */
+ SUCCESSED
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,34 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ *
+ * Le contrat a implanter pour une etapes dans le modèle de wizard avec
+ * opérations.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardOperationStep extends WizardStep {
+
+ /**
+ * @return le label de l'opération
+ */
+ String getOperationLabel();
+
+ /**
+ * @return la description de l'opération
+ */
+ String getOperationDescription();
+
+ /**
+ * @return le type de l'action associée à l'étape ou <code>null</code> si
+ * l'étape n'a pas d'opération associée.
+ */
+ Class<? extends WizardOperationAction> getActionClass();
+
+ /**
+ * @return <code>true</code> si l'étape a une opération associée,
+ * <code>false</code> sinon.
+ */
+ boolean isOperation();
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,20 @@
+package jaxx.runtime.swing.wizard;
+
+import java.io.Serializable;
+
+/**
+ * le contrat d'une étape d'un wizard.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardStep extends Serializable {
+
+ String name();
+
+ int ordinal();
+
+ String getLabel();
+
+ String getDescription();
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,14 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ * Le contrat d'une ui d'étape.
+ *
+ * @param <E> le type d'étape
+ * @param <M> le type de modèle
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardStepUI<E extends WizardStep, M extends WizardModel<E>> {
+
+ E getStep();
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.JTabbedPane;
+
+/**
+ *
+ * Contrat a respecter pour une ui de wizard.
+ *
+ * @param <E> le type d'etape
+ * @param <M> le type de model
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> {
+
+ /**
+ * @return le modèle de wizard
+ */
+ M getModel();
+
+ /**
+ *
+ * @return l'étape courante
+ */
+ E getSelectedStep();
+
+ /**
+ *
+ * @return l'ui de l'étape courante
+ */
+ WizardStepUI<E, M> getSelectedStepUI();
+
+ /**
+ *
+ * @param step l'étape donnée
+ * @return l'ui de l'étape donnée
+ */
+ WizardStepUI<E, M> getStepUI(E step);
+
+ /**
+ *
+ * @param stepIndex la position de l'étape
+ * @return l'ui de l'étape donée
+ */
+ WizardStepUI<E, M> getStepUI(int stepIndex);
+
+ /**
+ * démarre le wizard
+ */
+ void start();
+
+ /**
+ * //TODO il faudrait supprimer cette méthode
+ * @return le conteneur d'ui d'étapes
+ */
+ JTabbedPane getTabs();
+
+ /**
+ * Méthode invoqué lorsque la première opération du modèlé a été démarrée.
+ */
+ void onWasStarted();
+
+ /**
+ * Méthode invoquée lorsque l'univers des étapes a été modifié dans le
+ * modèle.
+ *
+ * @param steps les nouvelles étapes
+ */
+ void onStepsChanged(E[] steps);
+
+ /**
+ * Méthode invoquée lorsque l'étape courante a changé dans le modèle.
+ *
+ * @param newStep la nouvelle étape courante
+ */
+ void onStepChanged(E newStep);
+
+ /**
+ * Méthode invoquée lorsque l'état interne du modèle a changé.
+ *
+ * @param newState le nouvelle état du modèle de wizard
+ */
+ void onModelStateChanged(WizardOperationState newState);
+
+ /**
+ * Méthode invoqué lorsque l'état d'une opération a changé.
+ *
+ * @param step l'étape dont l'état a changé
+ * @param newState le nouvel état pour l'étape donné
+ */
+ void onOperationStateChanged(E step,WizardOperationState newState) ;
+
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,162 @@
+package jaxx.runtime.swing.wizard;
+
+import java.awt.Window;
+import javax.swing.ImageIcon;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.beanutils.ConstructorUtils;
+
+/**
+ *
+ * Une classe pour lancer une ui de wizard.
+ *
+ * @param <E> le type des etapes
+ * @param <M> le type de modele
+ * @param <UI> le type d'ui
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardUILancher<E extends WizardStep, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
+
+ protected UI ui;
+
+ public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, String title, String tip, ImageIcon icon) {
+ this(context, uiClass, modelClass, null, title, tip, icon);
+ }
+
+ public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) {
+ try {
+ ui = createUI(context, uiClass, modelClass, model, title, tip, icon);
+ } catch (Exception ex) {
+ throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) {
+ try {
+ ui = createUI(context, mainUI, uiClass, modelClass, model);
+ } catch (Exception ex) {
+ throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass) {
+ this(context, mainUI, uiClass, modelClass, null);
+ }
+
+ public void start() {
+ init(ui);
+ start(ui);
+ }
+
+ protected void start(UI ui) {
+ ui.start();
+ }
+
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ if (ui == null) {
+ throw new NullPointerException("ui can not be null");
+ }
+ if (!(ui instanceof JAXXObject)) {
+ throw new ClassCastException("ui can not be casted to JAXXObject ");
+ }
+
+ return ((JAXXObject) ui).getContextValue(clazz, name);
+ }
+
+ public <T> T getContextValue(Class<T> clazz) {
+ return getContextValue(clazz, null);
+ }
+
+ protected void init(UI ui) {
+ }
+
+ protected void doAction(UI ui) {
+ }
+
+ protected void doCancel(UI ui) {
+ }
+
+ protected void doClose(UI ui, boolean wasCanceld) {
+ }
+
+ @SuppressWarnings("unchecked")
+ protected UI createUI(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) throws Exception {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(mainUI == null ? context : mainUI);
+ // parent context model
+ uiContext.add(modelClass.newInstance());
+ if (model != null) {
+ uiContext.add("incoming", model);
+ }
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doAction(ui);
+ } finally {
+ doClose(ui, false);
+ }
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doCancel(ui);
+ } finally {
+ doClose(ui, true);
+ }
+ }
+ });
+
+ // instanciate ui
+
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{Window.class, JAXXContext.class});
+ return newUI;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected UI createUI(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) throws Exception {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(context);
+ // parent context model
+ uiContext.add(modelClass.newInstance());
+ if (model != null) {
+ uiContext.add("incoming", model);
+ }
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doAction(ui);
+ } finally {
+ doClose(ui, false);
+ }
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doCancel(ui);
+ } finally {
+ doClose(ui, true);
+ }
+ }
+ });
+
+ // instanciate ui
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{uiContext, title, tip, icon}, new Class[]{JAXXContext.class, String.class, String.class, ImageIcon.class});
+ return newUI;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,157 @@
+package jaxx.runtime.swing.wizard;
+
+import java.awt.Component;
+import java.beans.IndexedPropertyChangeEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.Array;
+import javax.swing.JTabbedPane;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Classe de méthodes utiles sur les wizard.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class WizardUtil {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(WizardUI.class);
+
+ protected WizardUtil() {
+ }
+
+ public static boolean acceptStates(WizardOperationState state, WizardOperationState... accepted) {
+ for (WizardOperationState s : accepted) {
+ if (s == state) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean rejectStates(WizardOperationState state, WizardOperationState... rejected) {
+ for (WizardOperationState s : rejected) {
+ if (s == state) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static void addDebugLogListener(final Log log, WizardModel<?> model) {
+ if (log.isDebugEnabled()) {
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.debug(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ }
+ });
+ }
+ }
+
+ public static void addTraceLogListener(final Log log, WizardModel<?> model) {
+ if (log.isTraceEnabled()) {
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ }
+ });
+ }
+ }
+
+ public static <E extends WizardStep, M extends WizardModel<E>> void installWizardUIListeners(final WizardUI<E, M> ui) {
+ ui.getModel().addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void propertyChange(PropertyChangeEvent evt) {
+ String propertyName = evt.getPropertyName();
+ if (WizardOperationModel.WAS_STARTED_PROPERTY_NAME.equals(propertyName)) {
+ ui.onWasStarted();
+ return;
+ }
+ if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) {
+ java.util.List<E> steps = (java.util.List<E>) evt.getNewValue();
+ ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size())));
+ return;
+ }
+ if (WizardModel.STEP_PROPERTY_NAME.equals(propertyName)) {
+ ui.onStepChanged((E) evt.getNewValue());
+ return;
+ }
+ if (WizardOperationModel.MODEL_STATE_PROPERTY_NAME.equals(propertyName)) {
+ //TODO should be unicast : only for good stepUI ?
+ ui.onModelStateChanged((WizardOperationState) evt.getNewValue());
+ return;
+ }
+ if (WizardOperationModel.OPERATION_STATE_PROPERTY_NAME.equals(propertyName)) {
+ IndexedPropertyChangeEvent e = (IndexedPropertyChangeEvent) evt;
+ int stepIndex = e.getIndex();
+ E step = ui.getModel().getSteps().get(stepIndex);
+ ui.onOperationStateChanged(step, (WizardOperationState) evt.getNewValue());
+ return;
+ }
+ }
+ });
+ }
+
+ /**
+ * Ajoute un listener sur le modele pour gere la politique d'affichage des
+ * onglets.
+ *
+ * Dans cette implantation, les onglets sont ouverts jusqu'a l'etape courante.
+ * Lorsque l'on revient en arrière, les onglets d'etapes superieurs sont
+ * fermes.
+ *
+ * @param <E> le type d'un etape de l'assistant
+ * @param <M> le type du modele de l'assistant
+ * @param ui l'ui de l'assitant
+ * @since 1.7.1
+ */
+ public static <E extends WizardStep, M extends WizardModel<E>> void addTabsDisplayUntilStepListener(final WizardUI<E, M> ui) {
+ // on écoute les changements d'étapes
+ ui.getModel().addPropertyChangeListener(WizardModel.STEP_PROPERTY_NAME, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ M model = (M) evt.getSource();
+ E oldStep = (E) evt.getOldValue();
+ E newStep = (E) evt.getNewValue();
+ log.debug("step has changed <old:" + oldStep + ", new:" + newStep + ">");
+ int oldStepIndex = oldStep == null ? -1 : model.getStepIndex(oldStep);
+ int newStepIndex = model.getStepIndex(newStep);
+ JTabbedPane tabs = ui.getTabs();
+ if (oldStepIndex + 1 == newStepIndex) {
+ // creation d'un nouvel onglet
+ WizardStepUI<E, M> c = ui.getStepUI(newStep);
+ String title = _(newStep.getLabel());
+ String tip = _(newStep.getDescription());
+ tabs.addTab(title, null, (Component) c, tip);
+ // selection du nouvel onglet
+ int index = tabs.indexOfComponent((Component) c);
+ if (index > -1) {
+ tabs.setSelectedIndex(index);
+ }
+ } else if (oldStepIndex > newStepIndex) {
+ // il s'agit d'un retour en arrière
+ // on supprime tous les onglets obsoletes
+ int index = newStepIndex + 1;
+ while (tabs.getTabCount() > index) {
+ log.trace("remove tab : " + index);
+ tabs.remove(index);
+ }
+ } else {
+ throw new IllegalStateException("can not go from " + oldStep + " to " + newStep);
+ }
+ }
+ });
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <h1>JAXX - Wizard framework</h1>
+
+ This package contains all the classes of the wizard framework.
+
+ TODO
+ </body>
+</html>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/package.html
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,6 +1,5 @@
package jaxx.runtime.validator;
-import jaxx.runtime.BeanValidatorUtil;
import java.beans.EventSetDescriptor;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -17,7 +17,7 @@
String[] messagestoAdd;
String[] messagestoDelete;
- public BeanValidatorEvent(BeanValidator source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+ public BeanValidatorEvent(BeanValidator<?> source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
super(source);
this.field = field;
this.scope = scope;
@@ -26,8 +26,8 @@
}
@Override
- public BeanValidator getSource() {
- return (BeanValidator) super.getSource();
+ public BeanValidator<?> getSource() {
+ return (BeanValidator<?>) super.getSource();
}
public String getFieldName() {
@@ -46,7 +46,7 @@
return scope;
}
- public BeanValidatorField getField() {
+ public BeanValidatorField<?> getField() {
return field;
}
}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -192,11 +192,11 @@
if (this == o) {
return true;
}
- if (!(o instanceof BeanValidatorField)) {
+ if (!(o instanceof BeanValidatorField<?>)) {
return false;
}
- BeanValidatorField that = (BeanValidatorField) o;
+ BeanValidatorField<?> that = (BeanValidatorField<?>) o;
return beanClass.equals(that.beanClass) && name.equals(that.name);
}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -8,16 +8,16 @@
* @author chemit
* @since 1.3
*/
-public class BeanValidatorMessage<E extends BeanValidatorMessage> implements Comparable<E> {
+public class BeanValidatorMessage<E extends BeanValidatorMessage<?>> implements Comparable<E> {
/**
* the validator that produce the message
*/
- protected BeanValidator validator;
+ protected BeanValidator<?> validator;
/**
* the field thatproduce the message
*/
- protected BeanValidatorField field;
+ protected BeanValidatorField<?> field;
/**
* the label of the message (to be displayed somewhere)
*/
@@ -27,18 +27,18 @@
*/
protected BeanValidatorScope scope;
- public BeanValidatorMessage(BeanValidator validator, BeanValidatorField field, String message, BeanValidatorScope scope) {
+ public BeanValidatorMessage(BeanValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope) {
this.field = field;
this.validator = validator;
this.message = message;
this.scope = scope;
}
- public BeanValidator getValidator() {
+ public BeanValidator<?> getValidator() {
return validator;
}
- public BeanValidatorField getField() {
+ public BeanValidatorField<?> getField() {
return field;
}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/BeanValidatorUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,176 @@
+package jaxx.runtime.validator;
+
+import jaxx.runtime.*;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import jaxx.runtime.validator.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author chemit
+ */
+public class BeanValidatorUtil {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
+ /**
+ * a shared value stack to allow external operations on it (for example
+ * add some datas in stack to be usedby validators
+ */
+ static private ValueStack sharedValueStack;
+
+ public static synchronized ValueStack getSharedValueStack() {
+ if (sharedValueStack == null) {
+
+ // init context
+ ConfigurationManager confManager = new ConfigurationManager();
+ Configuration conf = confManager.getConfiguration();
+
+ sharedValueStack = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+ if (log.isDebugEnabled()) {
+ log.debug("init shared value stack " + sharedValueStack);
+ }
+ }
+ return sharedValueStack;
+ }
+
+ protected BeanValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Convinient method to attach a bean to all validators of an JAXXObject.
+ * <p/>
+ * It is possible to exclude some validator to be treated.
+ *
+ * @param ui the ui containing the validatros to treate
+ * @param bean the bean to attach in validators (can be null)
+ * @param excludeIds the list of validator id to exclude
+ */
+ @SuppressWarnings({"unchecked"})
+ public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
+ if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
+ return;
+ }
+ JAXXValidator jaxxValidator = (JAXXValidator) ui;
+ List<String> validatorIds = jaxxValidator.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
+ // touch validator, only if fits the bean type (or bean is null)
+ beanValidator.setBean(bean);
+ }
+ }
+ }
+
+ /**
+ * Convinient method to set the changed property to all validators of an JAXXObject.
+ * <p/>
+ * It is possible to exclude some validator to be treated.
+ *
+ * @param ui the ui containing the validatros to treate
+ * @param newValue the new value to set in changed validator property
+ * @param excludeIds the list of validator id to exclude
+ */
+ @SuppressWarnings({"unchecked"})
+ public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
+ if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
+ return;
+ }
+ JAXXValidator jaxxValidator = (JAXXValidator) ui;
+ List<String> validatorIds = jaxxValidator.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ beanValidator.setChanged(newValue);
+ }
+ }
+
+ /**
+ * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
+ *
+ * @param validator validator to be involved
+ * @param fieldName the name of the bean property
+ * @param value the actual value to convert
+ * @param valueClass the type of the conversion
+ */
+ public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
+
+ Object result = validator.convert(fieldName, value, valueClass);
+ if (result != null) {
+ try {
+ BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
+
+ for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
+ if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
+
+ descriptor.getWriteMethod().invoke(validator.getBean(), result);
+ break;
+ }
+ }
+ } catch (IntrospectionException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ }
+ } else {
+ //fixme : conversion failed, we should be able to notify ui that values has changed ?
+ // otherwise, bean value has not changed,...
+ }
+ }
+
+ public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
+ try {
+ // check that the bean is listenable, otherwise, can't use
+ // the validator on it
+ BeanInfo infos = Introspector.getBeanInfo(beanClass);
+ EventSetDescriptor[] events = infos.getEventSetDescriptors();
+ for (EventSetDescriptor event : events) {
+ if ("propertyChange".equals(event.getName())) {
+
+ if (event.getAddListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
+ }
+ if (event.getRemoveListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
+ }
+ return event;
+ }
+ }
+
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
+ } catch (IntrospectionException ex) {
+ throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -20,7 +20,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import jaxx.runtime.BeanValidatorUtil;
/**
*
@@ -182,10 +181,10 @@
}
if (validationContext.hasFieldErrors()) {
- Map messages = validationContext.getFieldErrors();
+ Map<?,?> messages = validationContext.getFieldErrors();
result = new HashMap<String, List<String>>(messages.size());
for (Object fieldName : messages.keySet()) {
- Collection c = (Collection) messages.get(fieldName);
+ Collection<?> c = (Collection<?>) messages.get(fieldName);
List<String> mm = new java.util.ArrayList<String>(c.size());
for (Object message : c) {
mm.add(message + "");
@@ -225,7 +224,7 @@
int skip = 0;
if (contextName != null && !includeDefaultContext) {
// count the number of validator to skip
- for (Validator v : validator.getValidators(beanClass, null)) {
+ for (Validator<?> v : validator.getValidators(beanClass, null)) {
// we only work on FieldValidator at the moment
if (v instanceof FieldValidator) {
skip++;
@@ -233,7 +232,7 @@
}
}
- for (Validator v : validator.getValidators(beanClass, contextName)) {
+ for (Validator<?> v : validator.getValidators(beanClass, contextName)) {
// we only work on FieldValidator at the moment
if (v instanceof FieldValidator) {
if (skip > 0) {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingDirectoryFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -41,6 +41,7 @@
*/
public class ExistingDirectoryFieldValidator extends FieldValidatorSupport {
+ @Override
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/ExistingFileFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -41,6 +41,7 @@
*/
public class ExistingFileFieldValidator extends FieldValidatorSupport {
+ @Override
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/field/RequiredFileFieldValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -41,6 +41,7 @@
*/
public class RequiredFileFieldValidator extends FieldValidatorSupport {
+ @Override
public void validate(Object object) throws ValidationException {
String fieldName = getFieldName();
Object value = this.getFieldValue(fieldName, object);
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,279 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
+import jaxx.runtime.validator.swing.ui.IconValidationUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import java.awt.Container;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import jaxx.runtime.validator.BeanValidator;
+import jaxx.runtime.validator.BeanValidatorField;
+
+/**
+ * La surcharge de {@link jaxx.runtime.validator.BeanValidator} pour les ui swing
+ * <p/>
+ * /**
+ * <p/>
+ * Permet d'ajouter facilement le support de la validation des champs d'un
+ * bean et de le relier a une interface graphique.
+ * Utilise xwork pour la validation et JXLayer pour la visualisation.
+ * <p/>
+ * <p/>
+ * Le mieux pour son integration dans Jaxx est de faire de la generation pour
+ * force la compilation du code suivant:
+ * <p/>
+ * <pre>
+ * myValidor.getBean().get<field>();
+ * </pre>
+ * <p/>
+ * et ceci pour chaque field ajoute a la map fieldRepresentation. De cette
+ * facon meme si le champs field est en texte on a une verification de son
+ * existance a la compilation.
+ * <p/>
+ * <p/>
+ * La representation en tag pourrait etre
+ * <pre>
+ * <validator id="myValidator" beanClass="{Personne.class}" errorList="$list">
+ * <field name="name" component="$name"/>
+ * <field name="firstName" component="$firstName"/>
+ * <field name="birthDate" component="$birthDate"/>
+ * </validator>
+ * <validator beanClass="{Personne.class}" autoField="true" errorList="$list">
+ * <fieldRepresentation name="name" component="$lastName"/>
+ * </validator>
+ * </pre>
+ * <p/>
+ * dans le premier exemple on fait un mapping explicite des champs, mais on voit
+ * que le nom du composant graphique est le meme que celui du champs. Pour eviter
+ * de longue saisie, il est possible d'utiliser le flag <b>autoField</b>
+ * qui pour chaque champs du ayant une methode get du bean recherche un composant
+ * avec cet Id. Il est aussi possible de surcharge un champs explicitement
+ * comme ici name, dans le cas ou le composant qui porterait ce nom serait
+ * utilise pour autre chose.
+ * <p/>
+ * <p/>
+ * Il faut un handler particulier pour ce composant car les attributs
+ * <b>beanClass</b> et <b>autoField</b> ne sont present que dans le XML jaxx et
+ * servent a la generation. Il faut aussi prendre en compte les elements
+ * fieldRepresentation fils du tag validator.
+ * <p/>
+ * <p/>
+ * Voici ce que pourrait etre le code genere par jaxx
+ * <pre>
+ * // declaration du bean
+ * BeanValidator<beanClass> $myValidator;
+ * // init du bean
+ * protected void createMyValidator() {
+ * $myValidator = new BeanValidator<beanClass>();
+ * // genere seulement si autoField = true
+ * for (Method m : beanClass.getMethod()) {
+ * if (m.getName().startsWith("get")) {
+ * String fieldName = m.getName().substring(3).toLowerCase();
+ * $myValidator.setFieldRepresentation(fieldName, $objectMap.get(fieldName));
+ * }
+ * }
+ * // pour chaque tag fieldRepresentation
+ * myValidator.setFieldRepresentation("name", $lastName);
+ * // si beanClass est specifie et n'est pas Object, on force l'acces au champs
+ * // pour validation a la compilation
+ * $myValidator.getBean().getName();
+ * $objectMap.put("myValidator", $myValidator);
+ * }
+ * </pre>
+ *
+ * @param <B> le type de bean a valider
+ * @author poussin
+ * @author chemit
+ * @version 1.0
+ */
+public class SwingValidator<B> extends BeanValidator<B> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingValidator.class);
+ static private final Class<? extends AbstractBeanValidatorUI> DEFAULT_UI_CLASS = IconValidationUI.class;
+ /** permet de faire le lien en un champs du bean et l'objet qui permet de l'editer */
+ protected Map<String, JComponent> fieldRepresentation;
+ /** Object servant a contenir la liste des erreurs */
+ protected SwingValidatorMessageListModel errorListModel;
+ /** Object servant a contenir la liste des erreurs */
+ protected SwingValidatorMessageTableModel errorTableModel;
+ /** ui renderer class */
+ protected Class<? extends AbstractBeanValidatorUI> uiClass;
+
+ public SwingValidator(Class<B> beanClass, String contextName) {
+ super(beanClass, contextName);
+ fieldRepresentation = new HashMap<String, JComponent>();
+ }
+
+ /**
+ * To reload a bean in the validator.
+ *
+ * This method is used to reload ui, since some editors
+ * could not exist when validator is init, so some messages
+ * should not be attached to an editor.
+ */
+ public void reloadBean() {
+ B b = getBean();
+ if (b != null) {
+ setBean(null);
+ setBean(b);
+ }
+ }
+
+ public JComponent getFieldRepresentation(String fieldname) {
+ return fieldRepresentation.get(fieldname);
+ }
+
+ public Class<? extends AbstractBeanValidatorUI> getUiClass() {
+ return uiClass;
+ }
+
+ public void setErrorListModel(SwingValidatorMessageListModel errorListModel) {
+ this.errorListModel = errorListModel;
+ if (errorListModel != null) {
+ // register the validator in the model list
+ errorListModel.registerValidator(this);
+ }
+ }
+
+ public void setErrorTableModel(SwingValidatorMessageTableModel errorTableModel) {
+ this.errorTableModel = errorTableModel;
+ if (errorTableModel != null) {
+ // register the validator in the model table
+ errorTableModel.registerValidator(this);
+ }
+ }
+
+ public void setUiClass(Class<? extends AbstractBeanValidatorUI> uiClass) {
+ this.uiClass = uiClass;
+ }
+
+ @Override
+ public void setContextName(String contextName) {
+ /*Map<ValidatorField<B>, List<ValidatorErrorListener>> oldListeners = new HashMap<ValidatorField<B>, List<ValidatorErrorListener>>();
+
+ for (ValidatorField<B> field : fields) {
+ ValidatorErrorListener[] listeners = field.getValidatorErrorListeners();
+ List<ValidatorErrorListener> toReinject = new ArrayList<ValidatorErrorListener>();
+ for (ValidatorErrorListener listener : listeners) {
+ if (listener instanceof AbstractBeanValidatorUI) {
+ // this listener will be reinject via installUIs method
+ continue;
+ }
+ toReinject.add(listener);
+ }
+ oldListeners.put(field, toReinject);
+ }*/
+ super.setContextName(contextName);
+ // must reinstall ui
+ installUIs();
+ // reinject none ui listeners
+ /*for (Entry<ValidatorField<B>, List<ValidatorErrorListener>> entry : oldListeners.entrySet()) {
+ ValidatorField<B> field = getField(entry.getKey().getName());
+ for (ValidatorErrorListener listener : entry.getValue()) {
+ field.addValidatorErrorListener(listener);
+ }
+ }
+ oldListeners.clear();*/
+ }
+
+ /**
+ * Permet d'indiquer le composant graphique responsable de l'affichage
+ * d'un attribut du bean
+ *
+ * @param fieldname the field name in the bean
+ * @param c the editor component for the field
+ */
+ public void setFieldRepresentation(String fieldname, JComponent c) {
+ BeanValidatorField<B> field = getField(fieldname);
+ if (field == null) {
+ // no field registred in the validator
+ log.warn("the field '" + fieldname + "' is not defined in validator (no rules on it)");
+ return;
+ }
+ fieldRepresentation.put(fieldname, c);
+ }
+
+ public void setFieldRepresentation(Map<String, JComponent> fieldRepresentation) {
+ for (Map.Entry<String, JComponent> e : fieldRepresentation.entrySet()) {
+ setFieldRepresentation(e.getKey(), e.getValue());
+ }
+ }
+
+ @Override
+ public SwingValidator<?> getParentValidator() {
+ return (SwingValidator<?>) super.getParentValidator();
+ }
+
+ public void setParentValidator(SwingValidator<?> parentValidator) {
+ super.setParentValidator(parentValidator);
+ }
+
+ /** install ui on required components */
+ public void installUIs() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (uiClass == null) {
+ // use the default one
+ uiClass = DEFAULT_UI_CLASS;
+ }
+ for (Entry<String, JComponent> entry : fieldRepresentation.entrySet()) {
+ try {
+ setMessageRepresentation(entry.getKey(), null, entry.getValue(), uiClass);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ });
+ }
+
+ protected void setMessageRepresentation(String fieldname, JComponent old, JComponent c, Class<? extends AbstractBeanValidatorUI> uiClass)
+ throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
+ if (old == c) {
+ // same component, nothing to do
+ return;
+ }
+ BeanValidatorField<B> field = getField(fieldname);
+
+ if (field == null) {
+ // this case should not appear since fieldName has already been check in method addFieldRepresentation
+ return;
+ }
+ if (old != null) {
+ // suppression du jxlayer sous l'ancien composant
+ Container container = old.getParent();
+ if (container instanceof JXLayer<?>) {
+ JXLayer<?> jx = (JXLayer<?>) container;
+ Object ui = jx.getUI();
+ if (ui != null && ui instanceof AbstractBeanValidatorUI) {
+ removeBeanValidatorListener((AbstractBeanValidatorUI) ui);
+ }
+
+ jx.setUI(null);
+ }
+ }
+ if (c != null) {
+ // ajout du jxlayer sous ce composant
+ Container container = c.getParent();
+ if (container instanceof JXLayer<?>) {
+ Constructor<? extends AbstractBeanValidatorUI> cons = uiClass.getConstructor(BeanValidatorField.class);
+ AbstractBeanValidatorUI ui = cons.newInstance(field);
+ ui.setEnabled(true);
+ JXLayer<JComponent> jx = (JXLayer<JComponent>) container;
+ addBeanValidatorListener(ui);
+ jx.setUI(ui);
+ }
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,66 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.JComponent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorMessage;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/**
+ * The object to box a validation message within an u.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see BeanValidatorMessage
+ */
+public class SwingValidatorMessage extends BeanValidatorMessage<SwingValidatorMessage> {
+
+ /**
+ * the optional field's editor
+ */
+ protected JComponent editor;
+ protected String fieldName;
+
+ public SwingValidatorMessage(SwingValidator<?> validator, BeanValidatorField<?> field, String message, BeanValidatorScope scope, JComponent editor) {
+ super(validator, field, message, scope);
+ this.fieldName = field.getName();
+ this.editor = editor;
+ }
+
+ public SwingValidatorMessage(SwingValidator<?> validator, String fieldName, String message, BeanValidatorScope scope, JComponent editor) {
+ super(validator, null, message, scope);
+ this.fieldName = fieldName;
+ this.editor = editor;
+ }
+
+ public JComponent getEditor() {
+ return editor;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ @Override
+ public int compareTo(SwingValidatorMessage o) {
+ // sort on scope
+ int result = getScope().compareTo(o.getScope());
+ if (result == 0) {
+ // sort on field name
+ result = fieldName.compareTo(o.getFieldName());
+ if (result == 0) {
+ // sort on message
+ result = message.compareTo(o.getMessage());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ String s = scope + " - " + (field == null ? message : field.getI18nError(message));
+ if (editor == null) {
+ return s;
+ }
+ return editor.getName() + " : " + s;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,142 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+
+import javax.swing.JComponent;
+import java.util.ArrayList;
+import java.util.List;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The model of the list of validation's messages
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageListModel
+ extends javax.swing.AbstractListModel
+ implements jaxx.runtime.validator.BeanValidatorListener {
+
+ private static final long serialVersionUID = 1L;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageListModel.class);
+ /** list of registred validators */
+ protected transient List<SwingValidator<?>> validators;
+ /** list of messages actual displayed */
+ protected List<SwingValidatorMessage> data;
+
+ public SwingValidatorMessageListModel() {
+ validators = new ArrayList<SwingValidator<?>>();
+ data = new java.util.ArrayList<SwingValidatorMessage>();
+ }
+
+ public boolean isEmpty() {
+ return getSize() == 0;
+ }
+
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
+ }
+
+ public void clear() {
+ int i = data.size();
+ if (i > 0) {
+ data.clear();
+ fireIntervalRemoved(this, 0, i - 1);
+ }
+ }
+
+ @Override
+ public int getSize() {
+ return data.size();
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ ensureRowIndex(index);
+ return data.get(index);
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorField<?> field = event.getField();
+ BeanValidatorScope scope = event.getScope();
+ boolean mustAdd = toAdd != null && toAdd.length > 0;
+ boolean mustDel = toDelete != null && toDelete.length > 0;
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getSize() + ") toAdd " + mustAdd);
+ log.trace(field + " - (" + getSize() + ") toDelete " + mustDel);
+ }
+
+ SwingValidator<?> validator = (SwingValidator<?>) event.getSource();
+
+ if (mustDel) {
+
+ // removes datas and notify if no messages to add
+ removeMessages(validator, field, scope, !mustAdd, toDelete);
+ }
+
+ if (mustAdd) {
+
+ // add new messages, sort datas and notify
+ addMessages(validator, field, scope, true, toAdd);
+ }
+ }
+
+ protected void ensureRowIndex(int index) throws ArrayIndexOutOfBoundsException {
+ if (index < -1 || index >= getSize()) {
+ throw new ArrayIndexOutOfBoundsException("the rowIndex was " + index + ", but should be int [0," + (getSize() - 1) + "]");
+ }
+ }
+
+ protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireIntervalAdded(this, data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireContentsChanged(this, 0, getSize() - 1);
+ }
+ }
+
+ protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getSize() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getField() == field && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireIntervalRemoved(this, i, i);
+ }
+ }
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,60 @@
+package jaxx.runtime.validator.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JComponent;
+import javax.swing.JList;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/**
+ * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageListModel} as a model.
+ * <p/>
+ * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageListMouseListener extends MouseAdapter {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(SwingValidatorMessageListMouseListener.class);
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ super.mouseClicked(e);
+ if (e.getClickCount() == 2) {
+
+ SwingValidatorMessage entry = getSelectedMessage(e);
+ if (entry == null) {
+ // no entry found
+ return;
+ }
+ JComponent component = entry.getEditor();
+ if (component != null) {
+ component.requestFocus();
+ }
+ }
+ }
+
+ protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
+ JList list = (JList) e.getSource();
+ if (!(list.getModel() instanceof SwingValidatorMessageListModel)) {
+ log.warn("model must be a " + SwingValidatorMessageListModel.class + ", but was " + list.getModel());
+ return null;
+ }
+
+ SwingValidatorMessageListModel model = (SwingValidatorMessageListModel) list.getModel();
+ int index = list.getSelectionModel().getMinSelectionIndex();
+ if (index == -1) {
+ // nothing is selected
+ return null;
+ }
+ SwingValidatorMessage entry = (SwingValidatorMessage) model.getElementAt(index);
+ if (log.isDebugEnabled()) {
+ log.debug("selected index: " + index + " : error: " + entry);
+ }
+ return entry;
+ }
+
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,89 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import jaxx.runtime.validator.BeanValidatorScope;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * A simple render of a table of validator's messages, says a table that use
+ * a {@link SwingValidatorMessageTableModel} model.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see SwingValidatorMessageTableModel
+ */
+public class SwingValidatorMessageListRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected String format = "%1$-20s - %2$s";
+ protected String formatTip = "%1$-20s - %2$-20s : %3$s";
+
+ public SwingValidatorMessageListRenderer() {
+ }
+
+ public SwingValidatorMessageListRenderer(String format) {
+ this.format = format;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+
+ JLabel rendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+
+ SwingValidatorMessage model = (SwingValidatorMessage) value;
+
+ // scope
+ ImageIcon icon = SwingValidatorUtil.getIcon(model.getScope());
+
+ // field name
+ String fieldName = getFieldName(list, model.getField().getName(), index);
+
+ // message
+ String message = getMessage(model);
+
+ // text to display
+ String text = String.format(format, fieldName, message);
+
+ String label = _(model.getScope().getLabel());
+ String tmp = _("validator.scope.tip", label);
+ String tmp2 = _("validator.field.tip", fieldName);
+
+ String tooltTipText = String.format(formatTip, tmp, tmp2, message);
+
+
+ rendererComponent.setText(text);
+ rendererComponent.setToolTipText(tooltTipText);
+ rendererComponent.setIcon(icon);
+
+ return rendererComponent;
+ }
+
+ public ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = SwingValidatorUtil.getIcon(scope);
+ return icon;
+ }
+
+ public String getMessage(SwingValidatorMessage model) {
+ String text = SwingValidatorUtil.getMessage(model);
+ return text;
+ }
+
+ public String getFieldName(JList list, String value, int row) {
+ SwingValidatorMessageListModel tableModel = (SwingValidatorMessageListModel) list.getModel();
+ SwingValidatorMessage model = (SwingValidatorMessage) tableModel.getElementAt(row);
+ String fieldName = SwingValidatorUtil.getFieldName(model, value);
+ return fieldName;
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,327 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+
+import javax.swing.JComponent;
+import java.util.ArrayList;
+import java.util.List;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The model of the table of errors.
+ *
+ * The model listens validators messages and update his internal model from it.
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public class SwingValidatorMessageTableModel
+ extends javax.swing.table.AbstractTableModel
+ implements jaxx.runtime.validator.BeanValidatorListener {
+
+ private static final long serialVersionUID = 1L;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+ public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
+ public static final Class<?>[] columnClasses = {BeanValidatorScope.class, String.class, String.class};
+ /** list of registred validators */
+ protected transient List<SwingValidator<?>> validators;
+ /** list of messages actual displayed */
+ protected List<SwingValidatorMessage> data;
+
+ public SwingValidatorMessageTableModel() {
+ super();
+ validators = new ArrayList<SwingValidator<?>>();
+ data = new java.util.ArrayList<SwingValidatorMessage>();
+ }
+
+ /**
+ * Register a validator for this model.
+ *
+ *
+ * Note: a validator can not be register twice in the same model.
+ *
+ * @param validator the validator to register
+ */
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
+ }
+
+ public void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ addMessages(validator, fieldName, scope, true, messages);
+ }
+
+ public void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, String... messages) {
+ addMessages(editor, fieldName, scope, true, messages);
+ }
+
+ public void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) {
+ addMessages(validator, field, scope, true, messages);
+ }
+
+ public void removeMessages(JComponent editor, BeanValidatorScope scope) {
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getEditor() == editor && (scope == null || error.getScope() == scope)) {
+ // remove the message
+ data.remove(i);
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+
+ public void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ removeMessages(validator, fieldName, scope, true, messages);
+ }
+
+ public void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope) {
+ removeMessages(editor, fieldName, scope, true);
+ }
+
+ public void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, String... messages) {
+ removeMessages(validator, field, scope, true, messages);
+ }
+
+ public void clear() {
+ int i = data.size();
+ if (i > 0) {
+ data.clear();
+ fireTableRowsDeleted(0, i - 1);
+ }
+ }
+
+ /**
+ * Obtain the message for a given row.
+ *
+ * @param rowIndex the row index
+ * @return the message for the given row index
+ */
+ public SwingValidatorMessage getRow(int rowIndex) {
+ ensureRowIndex(rowIndex);
+ return data.get(rowIndex);
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ // cells are never editable in this model
+ return false;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ ensureColumnIndex(columnIndex);
+ return columnClasses[columnIndex];
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ ensureColumnIndex(column);
+ return columnNames[column];
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorField<?> field = event.getField();
+ BeanValidatorScope scope = event.getScope();
+ boolean mustAdd = toAdd != null && toAdd.length > 0;
+ boolean mustDel = toDelete != null && toDelete.length > 0;
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getRowCount() + ") toAdd " + mustAdd);
+ log.trace(field + " - (" + getRowCount() + ") toDelete " + mustDel);
+ }
+
+ SwingValidator<?> validator = (SwingValidator<?>) event.getSource();
+
+ if (mustDel) {
+
+ // removes datas and notify if no messages to add
+ removeMessages(validator, field, scope, !mustAdd, toDelete);
+ }
+
+ if (mustAdd) {
+
+ // add new messages, sort datas and notify
+ addMessages(validator, field, scope, true, toAdd);
+ }
+ }
+
+ @Override
+ public int getRowCount() {
+ return data.size();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columnNames.length;
+ }
+
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ ensureColumnIndex(columnIndex);
+ ensureRowIndex(rowIndex);
+
+ SwingValidatorMessage row = data.get(rowIndex);
+ if (columnIndex == 0) {
+ // the icon
+ return row.getScope();
+ }
+ if (columnIndex == 1) {
+ // the field
+ return row.getFieldName();
+ }
+ if (columnIndex == 2) {
+ // the message
+ return row.getMessage();
+ }
+
+ // should never come here
+ return null;
+ }
+
+ protected void ensureRowIndex(int rowIndex) throws ArrayIndexOutOfBoundsException {
+ if (rowIndex < -1 || rowIndex >= getRowCount()) {
+ throw new ArrayIndexOutOfBoundsException("the rowIndex was " + rowIndex + ", but should be int [0," + (getRowCount() - 1) + "]");
+ }
+ }
+
+ protected void ensureColumnIndex(int index) throws ArrayIndexOutOfBoundsException {
+ if (index < -1 || index >= getColumnCount()) {
+ throw new ArrayIndexOutOfBoundsException("the columnIndex was " + index + ", but should be int [0," + (getColumnCount() - 1) + "]");
+ }
+ }
+
+ protected void addMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator == null ? null : validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void addMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator == null ? null : validator.getFieldRepresentation(fieldName);
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, fieldName, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(null, fieldName, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
+ }
+
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void removeMessages(SwingValidator<?> validator, BeanValidatorField<?> field, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(field.getName()) && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+ }
+
+ protected void removeMessages(SwingValidator<?> validator, String fieldName, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(fieldName) && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+ }
+
+ protected void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean notify) {
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getEditor() == editor && (scope == null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,94 @@
+package jaxx.runtime.validator.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageTableModel} as a model.
+ * <p/>
+ * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageTableMouseListener extends MouseAdapter {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+
+ public static final String HIGHLIGHT_ERROR_PROPERTY = "highlightError";
+
+ /** delgate property change support */
+ protected PropertyChangeSupport pcs;
+
+ public SwingValidatorMessageTableMouseListener() {
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ super.mouseClicked(e);
+ if (e.getClickCount() == 2) {
+
+ SwingValidatorMessage entry = getSelectedMessage(e);
+ if (entry == null) {
+ // no entry found
+ return;
+ }
+ JComponent component = entry.getEditor();
+ if (component != null) {
+ pcs.firePropertyChange(HIGHLIGHT_ERROR_PROPERTY, null, entry);
+ if (component.isVisible()) {
+ component.requestFocus();
+ }
+ }
+ }
+ }
+
+
+ protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
+ JTable table = (JTable) e.getSource();
+ if (!(table.getModel() instanceof SwingValidatorMessageTableModel)) {
+ log.warn("model must be a " + SwingValidatorMessageTableModel.class + ", but was " + table.getModel());
+ return null;
+ }
+
+ SwingValidatorMessageTableModel model = (SwingValidatorMessageTableModel) table.getModel();
+ int index = table.getSelectionModel().getMinSelectionIndex();
+ if (index == -1) {
+ // nothing is selected
+ return null;
+ }
+ if (table.getRowSorter() != null) {
+ index = table.getRowSorter().convertRowIndexToModel(index);
+ }
+ SwingValidatorMessage entry = model.getRow(index);
+ if (log.isDebugEnabled()) {
+ log.debug("selected index: " + index + " : error: " + entry);
+ }
+ return entry;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,83 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.Component;
+import jaxx.runtime.validator.BeanValidatorScope;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * A simple render of a table of validator's messages, says a table that use
+ * a {@link SwingValidatorMessageTableModel} model.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see SwingValidatorMessageTableModel
+ */
+public class SwingValidatorMessageTableRenderer extends DefaultTableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ ImageIcon icon = null;
+ String text = null;
+ String toolTipText = null;
+
+ column = table.convertColumnIndexToModel(column);
+ if (table.getRowSorter() != null) {
+ row = table.getRowSorter().convertRowIndexToModel(row);
+ }
+
+
+ switch (column) {
+ case 0:
+ // scope
+ BeanValidatorScope scope = (BeanValidatorScope) value;
+ icon = SwingValidatorUtil.getIcon(scope);
+ String label = _(scope.getLabel());
+ toolTipText = _("validator.scope.tip", label);
+ break;
+
+ case 1:
+ // field name
+ text = getFieldName(table, (String) value, row);
+ toolTipText = _("validator.field.tip", text);
+ break;
+
+ case 2:
+ // message
+ text = getMessage(table, (String) value, row);
+ toolTipText = _("validator.message.tip", text);
+ break;
+ }
+
+ rendererComponent.setText(text);
+ rendererComponent.setToolTipText(toolTipText);
+ rendererComponent.setIcon(icon);
+ return rendererComponent;
+ }
+
+ public ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = SwingValidatorUtil.getIcon(scope);
+ return icon;
+ }
+
+ public String getMessage(JTable table, String value, int row) {
+ SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessage model = tableModel.getRow(row);
+ String text = SwingValidatorUtil.getMessage(model);
+ return text;
+ }
+
+ public String getFieldName(JTable table, String value, int row) {
+ SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessage model = tableModel.getRow(row);
+ String fieldName = SwingValidatorUtil.getFieldName(model, value);
+ return fieldName;
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/SwingValidatorUtil.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,201 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.*;
+import jaxx.runtime.validator.BeanValidatorUtil;
+import jaxx.runtime.validator.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JList;
+import javax.swing.JTable;
+import java.awt.event.MouseListener;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.RowSorter;
+import javax.swing.SortOrder;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessage;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import static org.nuiton.i18n.I18n.n_;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author chemit
+ */
+public class SwingValidatorUtil extends BeanValidatorUtil {
+
+ static ImageIcon errorIcon;
+ static ImageIcon warningIcon;
+ static ImageIcon infoIcon;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingValidatorUtil.class);
+
+ public static ImageIcon getErrorIcon() {
+ if (errorIcon == null) {
+ errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
+ }
+ return errorIcon;
+ }
+
+ public static ImageIcon getInfoIcon() {
+ if (infoIcon == null) {
+ infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
+ }
+ return infoIcon;
+ }
+
+ public static ImageIcon getWarningIcon() {
+ if (warningIcon == null) {
+ warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
+ }
+ return warningIcon;
+ }
+
+ protected SwingValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Prepare the ui where to display the validators messages.
+ *
+ * @param errorTable the table where to display validators messages
+ * @param render renderer to use
+ */
+ public static void installUI(JTable errorTable, SwingValidatorMessageTableRenderer render) {
+ errorTable.setDefaultRenderer(Object.class, render);
+ errorTable.getRowSorter().setSortKeys(java.util.Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
+ SwingUtil.setI18nTableHeaderRenderer(errorTable,
+ n_("validator.scope.header"),
+ n_("validator.scope.header.tip"),
+ n_("validator.field.header"),
+ n_("validator.field.header.tip"),
+ n_("validator.message.header"),
+ n_("validator.message.header.tip"));
+ // register a single 'goto widget error' mouse listener on errorTable
+ registerErrorTableMouseListener(errorTable);
+ SwingUtil.fixTableColumnWidth(errorTable, 0, 25);
+ }
+
+ /**
+ * Register for a given validator list ui a validator mouse listener.
+ *
+ * Note: there is only one listener registred for a given list model, so
+ * invoking this method tiwce or more will have no effect.
+ *
+ * @param list the validation ui list
+ * @return the listener instanciate or found
+ * @see SwingValidatorMessageListMouseListener
+ */
+ public static SwingValidatorMessageListMouseListener registerErrorListMouseListener(JList list) {
+ SwingValidatorMessageListMouseListener listener = getErrorListMouseListener(list);
+
+ if (listener != null) {
+ return listener;
+ }
+ listener = new SwingValidatorMessageListMouseListener();
+ if (log.isDebugEnabled()) {
+ log.debug(listener.toString());
+ }
+ list.addMouseListener(listener);
+ return listener;
+ }
+
+ /**
+ * Register for a given validator table ui a validator mouse listener
+ *
+ * Note: there is onlt one listener registred for a givne table model, so
+ * invokin this method twice or more will have no effect.
+ *
+ * @param table the validator table ui
+ * @return the listener instanciate or found
+ * @see SwingValidatorMessageTableMouseListener
+ */
+ public static SwingValidatorMessageTableMouseListener registerErrorTableMouseListener(JTable table) {
+ SwingValidatorMessageTableMouseListener listener = getErrorTableMouseListener(table);
+
+ if (listener != null) {
+ return listener;
+ }
+ listener = new SwingValidatorMessageTableMouseListener();
+ if (log.isDebugEnabled()) {
+ log.debug(listener.toString());
+ }
+ table.addMouseListener(listener);
+ return listener;
+ }
+
+ /**
+ * @param list the validator list ui
+ * @return the validator list mouse listener, or <code>null</code> if not found
+ * @see SwingValidatorMessageListMouseListener
+ */
+ public static SwingValidatorMessageListMouseListener getErrorListMouseListener(JList list) {
+ if (list != null) {
+ for (MouseListener listener : list.getMouseListeners()) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageListMouseListener) listener;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param table the validator table ui
+ * @return the validator table mouse listener, or <code>null</code> if not found
+ * @see SwingValidatorMessageTableMouseListener
+ */
+ public static SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) {
+ if (table != null) {
+ for (MouseListener listener : table.getMouseListeners()) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageTableMouseListener) listener;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String getMessage(SwingValidatorMessage model) {
+ String text = model.getMessage();
+ if (model.getField() != null) {
+ text = model.getField().getI18nError(text);
+ }
+ return text;
+ }
+
+ public static String getFieldName(SwingValidatorMessage model, String value) {
+ String text = null;
+ JComponent editor = model.getEditor();
+ if (editor != null) {
+ text = (String) editor.getClientProperty("validatorLabel");
+ /*if (l != null) {
+ text = I18n._(l);
+ } else {
+ // TODO should try the text
+ }*/
+ }
+ if (text == null) {
+ text = value;
+ }
+ return text;
+ }
+
+ public static ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = getErrorIcon();
+ break;
+ case WARNING:
+ icon = getWarningIcon();
+ break;
+ case INFO:
+ icon = getInfoIcon();
+ break;
+ }
+ return icon;
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,37 @@
+package jaxx.runtime.validator.swing.ui;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.plaf.AbstractLayerUI;
+
+/**
+ * Abstract renderer
+ *
+ * @author chemit
+ */
+public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<javax.swing.JComponent> implements BeanValidatorListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class);
+ /** the field to render */
+ protected BeanValidatorField<?> field;
+
+ public AbstractBeanValidatorUI(BeanValidatorField<?> field) {
+ this.field = field;
+ if (log.isDebugEnabled()) {
+ log.debug("install " + this + "<field:" + field + ">");
+ }
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ if (field.equals(event.getField())) {
+ // ask to repaint the layer
+ setDirty(true);
+ }
+ }
+
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,86 @@
+package jaxx.runtime.validator.swing.ui;
+
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.BorderFactory;
+import javax.swing.JComponent;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/** @author chemit */
+public class IconValidationUI extends AbstractBeanValidatorUI {
+
+ // The icon to be shown at the layer's corner
+ protected static BufferedImage errorIcon;
+ protected static BufferedImage warningIcon;
+ protected static BufferedImage infoIcon;
+
+ public IconValidationUI(BeanValidatorField<?> field) {
+ super(field);
+ if (errorIcon == null) {
+ errorIcon = prepareIcon(Color.RED);
+ }
+ if (warningIcon == null) {
+ warningIcon = prepareIcon(Color.ORANGE);
+ }
+ if (infoIcon == null) {
+ infoIcon = prepareIcon(Color.GREEN);
+ }
+ }
+
+ @Override
+ public void installUI(JComponent c) {
+ super.installUI(c);
+ c.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 3));
+ }
+
+ @Override
+ public void uninstallUI(JComponent c) {
+ super.uninstallUI(c);
+ c.setBorder(null);
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ // There is no need to take insets into account for this painter
+ BeanValidatorScope scope = field.getScope();
+ if (scope != null) {
+ BufferedImage icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ if (icon != null) {
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+ }
+ }
+ }
+
+ protected static BufferedImage prepareIcon(Color color) {
+ int width = 7;
+ int height = 8;
+ BufferedImage icon = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.setColor(color);
+ g2.fillRect(0, 0, width, height);
+ g2.setColor(Color.WHITE);
+ g2.drawLine(0, 0, width, height);
+ g2.drawLine(0, height, width, 0);
+ g2.dispose();
+ return icon;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,78 @@
+package jaxx.runtime.validator.swing.ui;
+
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.BorderFactory;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/** @author chemit */
+public class ImageValidationUI extends AbstractBeanValidatorUI {
+
+ protected static BufferedImage errorIcon;
+ protected static BufferedImage warningIcon;
+ protected static BufferedImage infoIcon;
+
+ public ImageValidationUI(BeanValidatorField<?> field) {
+ super(field);
+ if (errorIcon == null) {
+ errorIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("error.png"));
+ }
+ if (warningIcon == null) {
+ warningIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("warning.png"));
+ }
+ if (infoIcon == null) {
+ infoIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("info.png"));
+ }
+ }
+
+ protected static BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ @Override
+ public void installUI(JComponent c) {
+ super.installUI(c);
+ c.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 3));
+ }
+
+ @Override
+ public void uninstallUI(JComponent c) {
+ super.uninstallUI(c);
+ c.setBorder(null);
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ BeanValidatorScope scope = field.getScope();
+ if (scope != null) {
+ BufferedImage icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ if (icon != null) {
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,65 @@
+package jaxx.runtime.validator.swing.ui;
+
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.jdesktop.jxlayer.JXLayer;
+
+import javax.swing.JComponent;
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import jaxx.runtime.validator.BeanValidatorField;
+
+/** @author chemit */
+public class TranslucentValidationUI extends AbstractBeanValidatorUI {
+
+ protected Color errorHightlight;
+ protected Color warningHightlight;
+ protected Color infoHightlight;
+
+ public TranslucentValidationUI(BeanValidatorField<?> field) {
+ super(field);
+ errorHightlight = Color.RED;
+ warningHightlight = Color.YELLOW;
+ infoHightlight = Color.GREEN;
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ // paints the layer as is
+ super.paintLayer(g2, l);
+
+ // to be in sync with the view if the layer has a border
+ Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+
+ BeanValidatorScope scope = field.getScope();
+
+ if (scope == null) {
+ g2.setColor(Color.WHITE);
+ } else {
+ switch (scope) {
+ case ERROR:
+ g2.setColor(errorHightlight);
+ break;
+ case WARNING:
+ g2.setColor(warningHightlight);
+ break;
+ case INFO:
+ g2.setColor(infoHightlight);
+ break;
+ }
+ }
+
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
+}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +0,0 @@
-validator.scope.error.label=Error
-validator.scope.info.label=Information
-validator.scope.warning.label=Warning
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +0,0 @@
-validator.scope.error.label=Erreur
-validator.scope.info.label=Information
-validator.scope.warning.label=Avertissement
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-en_GB.properties)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,12 @@
+validator.field.header=Field
+validator.field.header.tip=The field involved
+validator.field.tip=Property '%1$s'
+validator.message.header=Message
+validator.message.header.tip=Message
+validator.message.tip=Message \: %1$s
+validator.scope.error.label=Error
+validator.scope.header=...
+validator.scope.header.tip=Severity of the message
+validator.scope.info.label=Information
+validator.scope.tip=Message scope \: '%1$s'
+validator.scope.warning.label=Warning
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (from rev 1558, branches/jaxx-2.X/jaxx-runtime-api/src/main/resources/i18n/jaxx-runtime-api-fr_FR.properties)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/resources/i18n/jaxx-runtime-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -0,0 +1,12 @@
+validator.field.header=Champ
+validator.field.header.tip=Le champ surquel intervient le message
+validator.field.tip=Propri\u00E9t\u00E9 '%1$s'
+validator.message.header=Message
+validator.message.header.tip=Le texte du message
+validator.message.tip=Message \: %1$s
+validator.scope.error.label=Erreur
+validator.scope.header=...
+validator.scope.header.tip=Le de type de message
+validator.scope.info.label=Information
+validator.scope.tip=Type de message \: '%1$s'
+validator.scope.warning.label=Avertissement
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-delete.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-config.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-message.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-next.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-pause.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-previous.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-refresh.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-start.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-canceled.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-failed.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-need_fix.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-pending.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-running.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed-16.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed-16.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed.png)
===================================================================
(Binary files differ)
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/action-wizard-state-successed.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/error.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/error.png)
===================================================================
(Binary files differ)
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/info.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/info.png)
===================================================================
(Binary files differ)
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/resources/icons/warning.png (from rev 1558, branches/jaxx-2.X/jaxx-runtime-swing/src/main/resources/icons/warning.png)
===================================================================
(Binary files differ)
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,163 +0,0 @@
-package jaxx.runtime;
-
-import jaxx.runtime.JXPathDecorator.Context;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/** @author chemit */
-public class JXPathDecoratorTest {
-
-
- protected JXPathDecorator<?> decorator;
- protected String expected;
- protected String result;
-
- @After
- public void after() {
- decorator = null;
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullInternalClass() throws Exception {
- decorator = JXPathDecorator.newDecorator(null, "hello");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "${haha");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace2() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "${haha${hum}");
- }
-
- @Test
- public void testNullBean() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "hello");
- expected = "hello";
- assertEquals(expected, decorator.getExpression());
- assertEquals(0, decorator.nbToken);
- assertEquals(0, decorator.getTokens().length);
-
- result = decorator.toString(null);
- assertEquals(null, result);
- }
-
- @Test
- public void testNoJXPath() throws Exception {
- decorator = JXPathDecorator.newDecorator(Object.class, "hello");
- expected = "hello";
- assertEquals(expected, decorator.getExpression());
- assertEquals(0, decorator.nbToken);
- assertEquals(0, decorator.getTokens().length);
-
- result = decorator.toString(this);
- assertEquals(expected, result);
- }
-
- @Test
- public void testDecorator() throws Exception {
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s - ${nbToken}$d");
- assertEquals("%1$s - %2$d", decorator.getExpression());
- assertDecoratorInternal();
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}${nbToken}");
- assertEquals("%1%2", decorator.getExpression());
- assertDecoratorInternal();
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before ${expression}$s - ${nbToken}$d after");
- assertEquals("before %1$s - %2$d after", decorator.getExpression());
- assertDecoratorInternal();
-
- decorator = JXPathDecorator.newDecorator(JXPathDecorator.class, "before${expression}$s-${nbToken}$dafter");
- assertEquals("before%1$s-%2$dafter", decorator.getExpression());
- assertDecoratorInternal();
- }
-
- public static class Data {
- int pos;
- String name;
-
- protected static List<Data> generate(int nb) {
- List<Data> datas = new ArrayList<Data>(nb);
- for (int i = 0; i < nb; i++) {
- datas.add(new Data(i, "name_" + (nb - i)));
- }
- return datas;
- }
-
- Data(int pos, String name) {
- this.pos = pos;
- this.name = name;
- }
-
- public int getPos() {
- return pos;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return "Data{pos=" + pos + ", name='" + name + '\'' + '}';
- }
- }
-
- @Test
- public void testSort() throws Exception {
-
- List<Data> datas = Data.generate(10);
- JXPathDecorator<Data> decorator = JXPathDecorator.newDecorator(Data.class, "${pos}$d ${name}$s");
-
- List<Data> sortData = new ArrayList<Data>(datas);
- JXPathDecorator.sort(decorator, sortData, 0);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- Collections.sort(datas, new Comparator<Data>() {
- @Override
- public int compare(Data o1, Data o2) {
- return o1.name.compareTo(o2.name);
- }
- });
- Context<Data> context = decorator.context;
- context.setComparator(null);
- JXPathDecorator.sort(decorator, sortData, 1);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- }
-
-
- public void assertDecoratorInternal(String... tokens) {
- assertTokens(tokens);
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- private void assertTokens(String... tokens) {
- if (tokens.length == 0) {
- tokens = new String[]{"expression", "nbToken"};
- }
- assertEquals(2, decorator.nbToken);
- assertEquals(2, decorator.getTokens().length);
- assertEquals(tokens[0], decorator.getTokens()[0]);
- assertEquals(tokens[1], decorator.getTokens()[1]);
- }
-
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/MultiJXPathDecoratorTest.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,184 +0,0 @@
-package jaxx.runtime;
-
-import jaxx.runtime.JXPathDecoratorTest.Data;
-import org.junit.After;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/** @author chemit */
-public class MultiJXPathDecoratorTest {
-
-
- protected MultiJXPathDecorator<?> decorator;
- protected String expected;
- protected String result;
-
- @After
- public void after() {
- decorator = null;
- }
-
- @Test(expected = NullPointerException.class)
- public void testNullInternalClass() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(null, "hello", "#");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(Object.class, "${haha", "#");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingRightBrace2() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(Object.class, "${haha${hum}", "#");
- }
-
- @Test
- public void testNullBean() throws Exception {
- decorator = MultiJXPathDecorator.newDecorator(Object.class, "hello", "");
- expected = "hello";
- assertEquals(expected, decorator.getExpression());
- assertEquals(0, decorator.nbToken);
- assertEquals(0, decorator.getTokens().length);
-
- result = decorator.toString(null);
- assertEquals(null, result);
- }
-
- @Test
- public void testMultiDecorator() throws Exception {
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d", "#", " - ");
- assertEquals("%1$s - %2$d", decorator.getExpression());
- assertDecoratorInternal();
- assertEquals(2, decorator.contexts.length);
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s", decorator.getExpression());
- assertTokens("nbToken", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s ## ${nbToken}$d", " ## ", " - ");
- assertEquals("%1$s - %2$d", decorator.getExpression());
- assertDecoratorInternal();
- assertEquals(2, decorator.contexts.length);
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s", decorator.getExpression());
- assertTokens("nbToken", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- @Test
- public void testMultiDecorator2() throws Exception {
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s", "#", " - ");
-
- assertEquals("%1$s - %2$d - %3$s", decorator.getExpression());
- assertTokens("expression", "nbToken", "separator");
- assertEquals(3, decorator.contexts.length);
-
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s - %3$s", decorator.getExpression());
- assertTokens("nbToken", "separator", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(2);
- assertEquals("%1$s - %2$s - %3$d", decorator.getExpression());
- assertTokens("separator", "expression", "nbToken");
-
- expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- @Test
- public void testMultiDecoratorWithMultiRef() throws Exception {
-
- decorator = MultiJXPathDecorator.newDecorator(JXPathDecorator.class, "${expression}$s#${nbToken}$d#${separator}$s %3$s", "#", " - ");
-
- assertEquals("%1$s - %2$d - %3$s %3$s", decorator.getExpression());
- assertTokens("expression", "nbToken", "separator");
- assertEquals(3, decorator.contexts.length);
-
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(1);
- assertEquals("%1$d - %2$s %3$s - %3$s", decorator.getExpression());
- assertTokens("nbToken", "separator", "expression");
- expected = String.format(decorator.getExpression(), decorator.getNbToken(), decorator.getSeparator(), decorator.getExpression());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
-
- decorator.setContextIndex(2);
- assertEquals("%1$s %3$s - %2$s - %3$d", decorator.getExpression());
- assertTokens("separator", "expression", "nbToken");
-
- expected = String.format(decorator.getExpression(), decorator.getSeparator(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- @Test
- public void testSort() throws Exception {
-
- List<Data> datas = Data.generate(10);
-
- MultiJXPathDecorator<Data> decorator = MultiJXPathDecorator.newDecorator(Data.class, "${pos}$d-${name}$s", "-");
-
- List<Data> sortData = new ArrayList<Data>(datas);
- JXPathDecorator.sort(decorator, sortData, 0);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- Collections.sort(datas, new Comparator<Data>() {
- @Override
- public int compare(Data o1, Data o2) {
- return o1.name.compareTo(o2.name);
- }
- });
- decorator.setContextIndex(1);
- JXPathDecorator.sort(decorator, sortData, 1);
- for (int i = 0; i < datas.size(); i++) {
- Data data = datas.get(i);
- Data sData = sortData.get(i);
- assertEquals(data, sData);
- }
- }
-
- public void assertDecoratorInternal(String... tokens) {
- assertTokens(tokens);
- expected = String.format(decorator.getExpression(), decorator.getExpression(), decorator.getNbToken());
- result = decorator.toString(decorator);
- assertEquals(expected, result);
- }
-
- private void assertTokens(String... tokens) {
- if (tokens.length == 0) {
- tokens = new String[]{"expression", "nbToken"};
- }
- assertEquals(tokens.length, decorator.nbToken);
- assertEquals(tokens.length, decorator.getTokens().length);
- for (int i = 0; i < tokens.length; i++) {
- assertEquals(tokens[i], decorator.getTokens()[i]);
- }
- }
-
-}
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-api/src/test/resources/log4j.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/resources/log4j.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -5,4 +5,4 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-log4j.logger.jaxx=DEBUG
+log4j.logger.jaxx=INFO
Modified: branches/jaxx-2.X/jaxx-swing-action/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-swing-action/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-swing-action/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -21,7 +21,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
@@ -42,8 +42,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx lutin library swing extension (tabs and actions)</description>
+ <name>JAXX Action</name>
+ <description>JAXX Action framework</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
Modified: branches/jaxx-2.X/jaxx-widgets/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,11 +10,11 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
- <artifactId>jaxx-runtime-swing-widget</artifactId>
+ <artifactId>jaxx-widgets</artifactId>
<dependencies>
@@ -22,7 +22,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
+ <artifactId>jaxx-runtime</artifactId>
<version>${project.version}</version>
</dependency>
@@ -47,8 +47,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx runtime swing widgets</description>
+ <name>JAXX Widgets</name>
+ <description>Collection of swing widgets wrote with JAXX</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -97,13 +97,9 @@
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<configuration>
- <silent>true</silent>
<entries>
<entry>
- <basedir>${maven.gen.dir}/java/</basedir>
- <includes>
- <param>**\/**.java</param>
- </includes>
+ <basedir>${maven.gen.dir}/java</basedir>
</entry>
</entries>
</configuration>
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBox.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -76,6 +76,7 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.decorator.JXPathDecorator;
public static final String DEFAULT_POPUP_LABEL = n_("entitycombobox.popup.label");
@@ -83,7 +84,7 @@
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) {
+public <O> void init(JXPathDecorator<O> decorator, java.util.List<O> data) {
handler.init(decorator, data);
}
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/EntityComboBoxHandler.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -19,9 +19,6 @@
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;
@@ -46,7 +43,11 @@
import java.lang.reflect.Method;
import java.util.List;
import javax.swing.JComboBox;
-import jaxx.runtime.Decorator;
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.decorator.JXPathDecorator;
+import jaxx.runtime.decorator.MultiJXPathDecorator;
+import jaxx.runtime.decorator.swing.DecoratorListCellRenderer;
+import jaxx.runtime.decorator.DecoratorUtils;
import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener;
/**
@@ -119,12 +120,12 @@
// should clone decorator ?
d = (MultiJXPathDecorator<O>) decorator;
} else {
- d = MultiJXPathDecorator.newDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - ");
+ d = DecoratorUtils.newMultiJXPathDecorator(decorator.getInternalClass(), decorator.getInitialExpression(), " - ");
}
this.decorator = d;
// init combobox renderer base on given decorator
- ui.getCombobox().setRenderer(Util.newDecoratedListCellRenderer(d));
+ ui.getCombobox().setRenderer(new DecoratorListCellRenderer(d));
this.convertor = newDecoratedObjectToStringConverter(d);
@@ -233,7 +234,7 @@
try {
// Sort data with the decorator jxpath tokens.
- JXPathDecorator.sort(decorator, ui.getData(), newValue);
+ DecoratorUtils.sort(decorator, ui.getData(), newValue);
} catch (Exception e) {
log.warn(e.getMessage(), e);
//System.out.println("newValue :: "+decorator+" : "+newValue);
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -2,8 +2,7 @@
aboutframe.license=License
aboutframe.ok=OK
aboutframe.thirdparty=Third party
-columnselection.action.tip=
-columnselector.action.tip=
+columnselector.action.tip=Select the columns
config.action.quit=Quit
config.action.quit.tip=Quit the configuration editor
config.action.reset=Cancel
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-runtime-swing-widget/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-05 19:15:44 UTC (rev 1559)
@@ -2,8 +2,7 @@
aboutframe.license=Licence
aboutframe.ok=OK
aboutframe.thirdparty=Tierce partie
-columnselection.action.tip=
-columnselector.action.tip=
+columnselector.action.tip=S\u00E9lectionner les colonnes
config.action.quit=Quitter
config.action.quit.tip=Quitter l'\u00E9diteur de configuration
config.action.reset=Annuler
Modified: branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
@@ -22,6 +22,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>jaxx-compiler</artifactId>
<version>${project.version}</version>
</dependency>
@@ -108,10 +114,9 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
+ <name>JAXX Maven plugin</name>
<description>
- Maven 2 plugin to generate java source from ui interface definitions
- in jaxx format.
+ Maven 2 plugin to generate java sources from JAXX files.
</description>
<!-- ************************************************************* -->
@@ -135,6 +140,188 @@
</plugin>
</plugins>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc.version}</version>
+ <configuration>
+ <taglets>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ </taglets>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<reporting>
@@ -142,6 +329,175 @@
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
</plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>${javadoc.version}</version>
+ <configuration>
+ <taglets>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-tools-javadoc</artifactId>
+ <version>2.4.2</version>
+ </tagletArtifact>
+ </taglet>
+
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ <taglet>
+ <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass>
+ <tagletArtifact>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-javadoc</artifactId>
+ <version>1.0</version>
+ </tagletArtifact>
+ </taglet>
+ </taglets>
+ </configuration>
+ </plugin>
</plugins>
</reporting>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -124,46 +124,6 @@
protected boolean checkPackaging() {
return project != null && !"pom".equals(project.getPackaging()) && !"site".equals(project.getPackaging());
}
-// @Override
-// public void execute() throws MojoExecutionException, MojoFailureException {
-//
-// try {
-// init();
-// } catch (Exception e) {
-// if (e instanceof MojoFailureException) {
-// throw (MojoFailureException) e;
-// }
-// if (e instanceof MojoExecutionException) {
-// throw (MojoExecutionException) e;
-// }
-// throw new MojoExecutionException("error in init : " + e.getMessage(), e);
-// }
-//
-// if (skip) {
-// if (verbose) {
-// getLog().info("jaxx - skip!");
-// }
-// return;
-// }
-//
-// try {
-//
-// doAction();
-//
-// } catch (Exception e) {
-// //getLog().error(e);
-// Throwable e2 = e;
-// while (e2.getCause() != null) {
-// e2 = e.getCause();
-// }
-// getLog().error(e2);
-//
-// throw new MojoExecutionException(e2.getMessage(), e2);
-// } finally {
-// System.gc();
-// }
-//
-// }
@Override
public MavenProject getProject() {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-05 19:15:44 UTC (rev 1559)
@@ -182,9 +182,9 @@
*/
protected String jaxxContextImplementorClass;
/**
- * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(String[])}.
+ * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
* <p/>
- * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(String[])}
+ * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
* <p/>
* and then will be use by {@link jaxx.tags.swing.SwingInitializer#initialize()}.
* <p/>
@@ -215,7 +215,8 @@
* If not given, will use the one defined in validator
*
* @parameter expression="${jaxx.defaultErrorUIFQN}"
- * @see jaxx.runtime.validator.swing.SwingValidator#DEFAULT_UI_CLASS
+ *
+ * @see jaxx.runtime.validator.swing.SwingValidator
*/
protected String defaultErrorUIFQN;
/**
@@ -284,13 +285,6 @@
if (skip) {
return true;
}
-//
-// if (project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) {
-// // nothing to be done for this type of packaging
-// skip = true;
-// getLog().info("skip generate goal for packaging " + project.getPackaging());
-// return true;
-// }
if (generateHelp) {
// check there is some bundle
@@ -475,14 +469,7 @@
return result;
}
- //TODO use the AbstractPublig method
protected void fixCompileSourceRoots() {
-// //fixme should remove this silly test when we will make real maven plugin tests :)
-// if (project != null) {
-// if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
-// project.addCompileSourceRoot(outJava.getPath());
-// }
-// }
if (project == null) {
// no project defined, can not fix anything
// this case could appears if we wanted to do some tests of the plugin
@@ -525,13 +512,6 @@
getLog().warn("??? : " + e.getMessage(), e);
}
}
-
- //fixme should remove this silly test when we will make real maven plugin tests :)
- if (getPluginContext() != null) {
- for (Object e : getPluginContext().keySet()) {
- getLog().info("pluginContext " + e + " : " + getPluginContext().get(e));
- }
- }
}
protected void checkJaxxContextImplementorClass() {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest1.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,3 @@
-<JComboBox>
+<JAXXComboBox>
<item value='Working' selected='true'/>
-</JComboBox>
\ No newline at end of file
+</JAXXComboBox>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JComboBoxTest2.jaxx 2009-10-05 19:15:44 UTC (rev 1559)
@@ -1,3 +1,3 @@
-<JComboBox>
+<JAXXComboBox>
<item value='Failed!'/>
-</JComboBox>
\ No newline at end of file
+</JAXXComboBox>
\ No newline at end of file
Modified: branches/jaxx-2.X/pom.xml
===================================================================
--- branches/jaxx-2.X/pom.xml 2009-10-05 13:18:45 UTC (rev 1558)
+++ branches/jaxx-2.X/pom.xml 2009-10-05 19:15:44 UTC (rev 1559)
@@ -14,18 +14,17 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>1.7.2-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
<modules>
- <module>jaxx-runtime-api</module>
- <module>jaxx-runtime-swing</module>
+ <module>jaxx-runtime</module>
<module>jaxx-compiler</module>
<module>jaxx-swing-action</module>
<module>maven-jaxx-plugin</module>
- <module>jaxx-runtime-swing-widget</module>
+ <module>jaxx-widgets</module>
<!-- deprecated since 1.7.2, will be removed before 2.0.0
<module>jaxx-example</module-->
@@ -256,7 +255,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.9</version>
+ <version>1.2.14</version>
</dependency>
<dependency>
@@ -308,8 +307,8 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>${project.artifactId}</name>
- <description>Jaxx library parent pom</description>
+ <name>JAXX Project</name>
+ <description>JAXX Project</description>
<inceptionYear>2008</inceptionYear>
<url>http://maven-site.nuiton.org/jaxx</url>
@@ -325,7 +324,7 @@
<projectId>jaxx</projectId>
<lutinutil.version>1.1.0</lutinutil.version>
- <i18n.version>1.0.1-SNAPSHOT</i18n.version>
+ <i18n.version>1.0.2-SNAPSHOT</i18n.version>
<jxlayer.version>3.0.3</jxlayer.version>
1
0
Author: tchemit
Date: 2009-10-05 15:18:45 +0200 (Mon, 05 Oct 2009)
New Revision: 1558
Added:
branches/jaxx-2.X/
Log:
create version 2.X of jaxx, with non compatible api with jaxx > 1.7.2
Property changes on: branches/jaxx-2.X
___________________________________________________________________
Added: svn:ignore
+ *.ipr
*.iws
*.iml
target
catalog.xml
*.log
Added: svn:mergeinfo
+
1
0
r1557 - trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by tchemit@users.nuiton.org 04 Oct '09
by tchemit@users.nuiton.org 04 Oct '09
04 Oct '09
Author: tchemit
Date: 2009-10-04 13:37:17 +0200 (Sun, 04 Oct 2009)
New Revision: 1557
Modified:
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
Log:
[Anomalie #73] fix NPE
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-04 10:12:06 UTC (rev 1556)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXComboBox.java 2009-10-04 11:37:17 UTC (rev 1557)
@@ -68,7 +68,7 @@
System.arraycopy(oldSelection, 0, newSelection, 0, index);
System.arraycopy(oldSelection, index + 1, newSelection, index, oldSelection.length - 1 - index);
}
- if (newSelection.length > 0){
+ if (newSelection.length > 0) {
setSelectedIndex(newSelection[0]);
}
} else {
@@ -90,10 +90,10 @@
}
}
- public List<Item> getItems(){
+ public List<Item> getItems() {
return items;
}
-
+
@Override
public Object getElementAt(int i) {
return items.get(i).getValue();
@@ -228,27 +228,29 @@
}
}
- public List<Item> getItems(){
- if (getModel() instanceof JAXXComboBoxModel){
- return ((JAXXComboBoxModel)getModel()).getItems();
+ public List<Item> getItems() {
+ if (getModel() instanceof JAXXComboBoxModel) {
+ return ((JAXXComboBoxModel) getModel()).getItems();
}
return null;
}
public void setSelectedItem(Item item) {
- super.setSelectedItem(item.getValue());
+ //TC-20092004 Anomalie #73 fix npe when want to call with a null
+ // value
+ super.setSelectedItem(item == null ? null : item.getValue());
}
- public Item getSelectedJaxxItem(){
+ public Item getSelectedJaxxItem() {
Object selected = super.getSelectedItem();
return findItem(selected);
}
- public Item findItem(Object value){
+ public Item findItem(Object value) {
List<Item> items = getItems();
- if (items != null){
- for (Item i : items){
- if (i.getValue().equals(value)){
+ if (items != null) {
+ for (Item i : items) {
+ if (i.getValue().equals(value)) {
return i;
}
}
@@ -256,33 +258,33 @@
return null;
}
- public void addItem(Item item){
+ public void addItem(Item item) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.add(item);
setItems(items);
}
}
- public void addAllItems(Collection<Item> itemsToAdd){
+ public void addAllItems(Collection<Item> itemsToAdd) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.addAll(itemsToAdd);
setItems(items);
}
}
- public void removeItem(Item item){
+ public void removeItem(Item item) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.remove(item);
setItems(items);
}
}
- public void removeAllItems(Collection<Item> itemsToRemove){
+ public void removeAllItems(Collection<Item> itemsToRemove) {
List<Item> items = getItems();
- if (items != null){
+ if (items != null) {
items.removeAll(itemsToRemove);
setItems(items);
}
1
0
04 Oct '09
Author: tchemit
Date: 2009-10-04 12:12:06 +0200 (Sun, 04 Oct 2009)
New Revision: 1556
Modified:
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
Log:
add usefull addExpandOnClickListener method
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-04 08:57:25 UTC (rev 1555)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-04 10:12:06 UTC (rev 1556)
@@ -19,6 +19,7 @@
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
+import javax.swing.event.TreeSelectionEvent;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
@@ -50,7 +51,10 @@
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.TreeSelectionListener;
import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
import jaxx.runtime.swing.BooleanCellRenderer;
import jaxx.runtime.swing.DecoratorTableCellRenderer;
import jaxx.runtime.swing.EmptyNumberTableCellRenderer;
@@ -755,4 +759,37 @@
}
});
}
+
+ /**
+ * Add a listener of tree selection model to expand a new selected node
+ * when it is selected.
+ *
+ * @param tree the tree to treate
+ */
+ public static void addExpandOnClickListener(final JTree tree) {
+
+ tree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(final TreeSelectionEvent e) {
+ TreeNode node = (TreeNode) e.getPath().getLastPathComponent();
+ if (node != null && !node.isLeaf()) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ for (TreePath path : e.getPaths()) {
+ if (e.isAddedPath(path) && !tree.isExpanded(path)) {
+ log.info("expand node [" + path + "]");
+ // will expand the node
+ tree.expandPath(path);
+ }
+ }
+ }
+ });
+ }
+ }
+ });
+ }
}
1
0
r1555 - in trunk/jaxx-demo/src/main: java/jaxx/demo java/jaxx/demo/component/jaxx/editor java/jaxx/demo/component/jaxx/navigation/full java/jaxx/demo/component/jaxx/navigation/item java/jaxx/demo/component/swing java/jaxx/demo/feature/databinding java/jaxx/demo/feature/validation java/jaxx/demo/fun resources/i18n
by tchemit@users.nuiton.org 04 Oct '09
by tchemit@users.nuiton.org 04 Oct '09
04 Oct '09
Author: tchemit
Date: 2009-10-04 10:57:25 +0200 (Sun, 04 Oct 2009)
New Revision: 1555
Added:
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java
Removed:
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
Log:
- add multi-sources in demo
- update license header
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo;
import java.io.IOException;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,73 +1,87 @@
+
<JTabbedPane id='top'>
<script><![CDATA[
- import java.io.*;
+import org.apache.commons.io.IOUtils;
- public DemoPanel(String... extraSources) {
- super();
-
- for (String extra : extraSources) {
- // creation du contenu du fichier
- JTextArea content = new JTextArea();
- content.setEditable(false);
- content.setText(loadSource(extra));
- // ajout de l'onglet
- top.addTab(extra,null,content,null);
- }
+protected String[] getSources() {
+ if (getClass() == DemoPanel.class) {
+ return new String[0];
}
+ return new String[]{ getDefaultSource() };
+}
- public String getLabel() {
- String name = getClass().getName();
- name = name.substring(name.lastIndexOf(".") + 1);
- if (name.endsWith("Demo"))
- name = name.substring(0, name.length() - "Demo".length());
- return name;
- }
-
+protected String getDefaultSource() {
+ return getClass().getSimpleName() + ".jaxx";
+}
- public String getDemoTabTitle() {
- return getLabel() + " Demo";
+public String getLabel() {
+ String name = getClass().getSimpleName();
+ if (name.endsWith("Demo")) {
+ name = name.substring(0, name.length() - "Demo".length());
}
+ return name;
+}
- public String loadSource(String filename) {
- try {
- Reader in = new InputStreamReader(getClass().getResourceAsStream(filename));
- StringWriter out = new StringWriter();
- char[] buffer = new char[2048];
- int c;
- while ((c = in.read(buffer)) > 0)
- out.write(buffer, 0, c);
- return out.toString();
+public String getDemoTabTitle() {
+ return getLabel() + " Demo";
+}
+
+public String loadSource(String filename) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(filename + " from " + getClass());
}
- catch (IOException e) {
- throw new RuntimeException(e);
- }
+ String result = IOUtils.toString(getClass().getResourceAsStream(filename));
+
+ return result;
+ } catch (Exception e) {
+ log.error("could not load file " + filename, e);
+ return "could not load file " + filename;
}
+}
- public String loadSource() {
- try {
- String className = getClass().getName();
- Reader in = new InputStreamReader(getClass().getResourceAsStream(className.substring(className.lastIndexOf(".") + 1) + ".jaxx"));
- StringWriter out = new StringWriter();
- char[] buffer = new char[2048];
- int c;
- while ((c = in.read(buffer)) > 0)
- out.write(buffer, 0, c);
- return out.toString();
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (getSources().length == 0) {
+ top.remove(sourceTabs);
+ return;
+ }
+ for (String extra : getSources()) {
+ JScrollPane pane = new JScrollPane(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ pane.setBorder(null);
+ // creation du contenu du fichier
+ JTextArea content = new JTextArea();
+ content.setFont(content.getFont().deriveFont((float) 11));
+ content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
+ content.setEditable(false);
+ content.setWrapStyleWord(false);
+ content.setText(loadSource(extra));
+ content.setColumns(80);
+ pane.getViewport().add(content);
+ // ajout de l'onglet
+ sourceTabs.addTab(extra, pane);
+ int index = sourceTabs.indexOfComponent(pane);
+ JLabel l = new JLabel(extra);
+ l.setFont(l.getFont().deriveFont((float) 10));
+ sourceTabs.setTabComponentAt(index,l);
+ }
}
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- ]]></script>
+ });
+}
+ ]]>
+ </script>
<tab title='{getDemoTabTitle()}'>
<JPanel id='demoPanel'/>
</tab>
- <!--tab title='Source'>
- <JScrollPane height='100'>
- <JTextArea text='{loadSource()}' editable='false'/>
- </JScrollPane>
- </tab-->
+ <tab title='Sources'>
+ <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
+ </tab>
</JTabbedPane>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo;
import java.util.Stack;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -73,7 +73,6 @@
selectionModel="{getTreeHelper().createTreeHandler(this)}"
cellRenderer='{new NavigationTreeCellRenderer(this, 200)}'>
</JTree>
- <!--model='{DemoTreeHelper.TREE_MODEL.getContextValue(this)}'-->
</JScrollPane>
<JPanel id='content'/>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,9 +1,10 @@
/**
- * *##% observe-swing
- * Copyright (C) 2008 - 2009 IRD
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
+ * it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
@@ -12,9 +13,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
- * You should have received a copy of the GNU General Public
+ * You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package jaxx.demo;
@@ -100,8 +102,8 @@
@Override
public void run() {
- // use best dimensions
- ui.getSplitPane().resetToPreferredSizes();
+// // use best dimensions
+// ui.getSplitPane().resetToPreferredSizes();
String path;
if (node == null) {
@@ -113,7 +115,19 @@
}
// select node
ui.getTreeHelper().selectNode(ui, ui.getNavigation(), path);
+//
+// // show ui
+// ui.setVisible(true);
+ }
+ });
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+
+ // use best dimensions
+ ui.getSplitPane().resetToPreferredSizes();
+
// show ui
ui.setVisible(true);
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo;
import jaxx.runtime.DefaultApplicationContext;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.component.jaxx.editor;
import java.beans.PropertyChangeListener;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,11 +1,9 @@
-
<JPanel layout='{new BorderLayout()}'>
<Object id='data' javaBean='helper.getSelectedBean(this)'/>
<script><![CDATA[
import jaxx.runtime.SwingUtil;
-import jaxx.demo.component.jaxx.navigation.full.model.*;
private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
@@ -73,7 +71,7 @@
verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
minimumSize='{SwingUtil.newMinDimension()}'>
- <JLabel icon='{getImage(getData())}'/>
+ <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/>
</JScrollPane>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -9,9 +9,14 @@
private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
-setContextValue(helper.createMovies(this), " movies");
+helper.createModel(this);
-void $afterCompleteSetup() {
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" };
+}
+
+private void $afterCompleteSetup() {
SwingUtilities.invokeLater(new Runnable() {
@Override
@@ -41,7 +46,6 @@
model='{helper.createTreeModel(this)}'
selectionModel="{helper.createTreeHandler(this)}"
cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />
- <!--model='{helper.createTreeModel(this, helper.createMovies())}'-->
</JScrollPane>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,8 +1,26 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.component.jaxx.navigation.full;
-import java.util.ArrayList;
-import java.util.HashSet;
-import jaxx.demo.component.jaxx.navigation.full.model.Movie;
+import java.util.Arrays;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
@@ -10,14 +28,13 @@
import static org.nuiton.i18n.I18n._;
import java.util.List;
-import java.util.Set;
-import jaxx.demo.component.jaxx.navigation.full.model.People;
import jaxx.runtime.Decorator;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.MultiJXPathDecorator;
import javax.swing.JPanel;
+import jaxx.runtime.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
@@ -35,15 +52,29 @@
*/
public class FullNavigationTreeHelper extends NavigationTreeHelper {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * Logger
+ */
static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+ /**
+ * where the movies are hold in context
+ */
+ static public final JAXXContextEntryDef<List<Movie>> MOVIES = JAXXContextEntryDef.newListDef("movies");
+ /**
+ * where the actors are hold in context
+ */
+ static public final JAXXContextEntryDef<List<People>> ACTORS = JAXXContextEntryDef.newListDef("actors");
public FullNavigationTreeHelper() {
super("full");
}
- public java.util.List<Movie> createMovies(JAXXContext context) {
- java.util.List<Movie> result = new java.util.ArrayList<Movie>();
+ /**
+ * Create the model and store it in the given context.
+ *
+ * @param context the context where to hold the model
+ */
+ public void createModel(JAXXContext context) {
People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
@@ -52,43 +83,38 @@
m.addActor(a);
m.addActor(a2);
m.addActor(a3);
- result.add(m);
- m = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
- m.addActor(a);
- m.addActor(a2);
- result.add(m);
+ Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m2.addActor(a);
+ m2.addActor(a2);
- context.setContextValue(result, "movies");
-
- return result;
+ MOVIES.setContextValue(context, Arrays.asList(m, m2));
+ ACTORS.setContextValue(context, Arrays.asList(a, a2, a3));
}
@Override
public NavigationTreeModel createTreeModel(JAXXContext context) {
- List<Movie> movies = context.getContextValue(List.class, "movies");
+ List<Movie> movies = MOVIES.getContextValue(context);
+ List<People> actors = ACTORS.getContextValue(context);
- log.info("for " + movies.size() + " movie(s)");
+ if (log.isDebugEnabled()) {
+ log.debug("for " + movies.size() + " movie(s)");
+ }
- NavigationTreeNode rootNode, moviesNode, movieNode, actorsNode;
-
- log.info("start creating demo model");
-
NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/");
- Decorator<Movie> movieDecorator = MultiJXPathDecorator.newDecorator(Movie.class, "${title}$s##${year}$s", "##", " - ");
- Decorator<People> peopleDecorator = MultiJXPathDecorator.newDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " ");
+ Decorator<Movie> mDecorator = MultiJXPathDecorator.newDecorator(Movie.class, "${title}$s##${year}$s", "##", " - ");
+ Decorator<People> pDecorator = MultiJXPathDecorator.newDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " ");
- Set<People> actors = new HashSet<People>();
// construction du noeud root
// il ne contient pas de context et ne sera pas visible
- rootNode = builder.buildEmptyRoot(null, "$root");
+ NavigationTreeNode rootNode = builder.buildEmptyRoot(null, "$root");
// construction du noeud avec les films recupere la liste des films
// dans le context avec la clef movies
// navigation path = $root/movies
- moviesNode = builder.build(
+ NavigationTreeNode moviesNode = builder.build(
rootNode,
_("movies"),
newListDef("movies"),
@@ -99,16 +125,16 @@
for (Movie m : movies) {
// navigation path = $root/movies/m.id
- movieNode = builder.build(
+ NavigationTreeNode movieNode = builder.build(
moviesNode,
- movieDecorator,
+ mDecorator,
"..[@id=\"" + m.getId() + "\"]",
m.getId(),
null,
null);
// navigation path = $root/movies/m.id/actors
- actorsNode = builder.build(
+ NavigationTreeNode actorsNode = builder.build(
movieNode,
_("actors"),
"../actors",
@@ -118,29 +144,26 @@
for (People p : m.getActors()) {
// navigation path = $root/movies/m.id/actors/p.id
-
builder.build(
actorsNode,
- peopleDecorator,
+ pDecorator,
"..[@id=\"" + p.getId() + "\"]",
p.getId(),
null,
null);
- actors.add(p);
}
}
// construction du noeud avec les acteurs
- actorsNode = builder.build(rootNode, _("actors"),
+ NavigationTreeNode actorsNode = builder.build(rootNode, _("actors"),
newListDef("actors"),
"actors", null, null);
for (People p : actors) {
// navigation path = $root/actors/p.id
-
builder.build(
actorsNode,
- peopleDecorator,
+ pDecorator,
"..[@id=\"" + p.getId() + "\"]",
p.getId(),
null,
@@ -148,24 +171,22 @@
}
NavigationTreeModel model = builder.getModel();
- context.setContextValue(movies, "movies");
- context.setContextValue(new ArrayList<People>(actors), "actors");
-
if (log.isDebugEnabled()) {
builder.printModel(context, model.getRoot());
}
// save tree model in context
setTreeModel(context, model);
-
return model;
}
+ @Override
public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+ if (log.isDebugEnabled()) {
+ log.debug("create handler");
+ }
- log.info("create handler");
-
NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout(
getPrefix(),
BaseContent.class,
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java (from rev 1552, trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -0,0 +1,127 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation.full;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java (from rev 1552, trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -0,0 +1,117 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation.full;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.component.jaxx.navigation.item;
import java.beans.PropertyChangeEvent;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -7,6 +7,11 @@
import jaxx.runtime.swing.navigation.*;
import org.jdesktop.swingx.JXDatePicker;
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "ExempleItemTreeNavigationAdapter.java" };
+}
+
void $afterCompleteSetup() {
new ExempleItemTreeNavigationAdapter(this, nav, content);
}
@@ -26,7 +31,7 @@
</item>
</JTree>
</JScrollPane>
- <!-- Card panel, only ItemNavigationPanel children is alowed -->
+ <!-- Card panel, only ItemNavigationPanel children is allowed -->
<ItemNavigationCardPanel id="content">
<!-- The associated type is passed by the constructor -->
<ItemNavigationPanel id='stringPanel' constructorParams='String.class' layout='{new FlowLayout()}'>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,23 +1,24 @@
-<jaxx.demo.DemoPanel>
- <script>
- private void displayMessage() {
- JOptionPane.showMessageDialog(demoPanel, "Menu item clicked");
- }
- </script>
-
- <JPanel id='demoPanel'>
- <JDesktopPane width='350' height='400' background='{null}'>
- <JInternalFrame title='JMenu demo' width='300' height='250' resizable='true'>
- <JMenuBar id='menuBar'>
- <JMenu text='Demo'>
- <JMenuItem text='Message Box' onActionPerformed='displayMessage()'/>
- </JMenu>
- </JMenuBar>
-
- <JPanel id='framePanel'>
- <JLabel text='JMenu demo' id='demoMessage' horizontalAlignment='center'/>
- </JPanel>
- </JInternalFrame>
- </JDesktopPane>
- </JPanel>
+<jaxx.demo.DemoPanel>
+ <script>
+ void $afterCompleteSetup(){}
+ private void displayMessage() {
+ JOptionPane.showMessageDialog(demoPanel, "Menu item clicked");
+ }
+ </script>
+
+ <JPanel id='demoPanel'>
+ <JDesktopPane width='350' height='400' background='{null}'>
+ <JInternalFrame title='JMenu demo' width='300' height='250' resizable='true'>
+ <JMenuBar id='menuBar'>
+ <JMenu text='Demo'>
+ <JMenuItem text='Message Box' onActionPerformed='displayMessage()'/>
+ </JMenu>
+ </JMenuBar>
+
+ <JPanel id='framePanel'>
+ <JLabel text='JMenu demo' id='demoMessage' horizontalAlignment='center'/>
+ </JPanel>
+ </JInternalFrame>
+ </JDesktopPane>
+ </JPanel>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -9,6 +9,7 @@
<String id='contentMessage' javaBean='"message..."'/>
<script>
+ void $afterCompleteSetup(){}
public Boolean isEditing2() { return editing2; }
public void setEditing2(Boolean newValue) {
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,7 +1,13 @@
<BaseBeanDataBinding>
<Boolean id='editing3' javaBean='true'/>
-
+ <script><![CDATA[
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseBeanDataBinding.jaxx" };
+}
+]]>
+ </script>
<Table id='demoPanel'>
<row>
<cell columns='2'>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.feature.validation;
import java.beans.PropertyChangeListener;
@@ -100,4 +120,4 @@
this.dir = dir;
p.firePropertyChange("dir", oldDir, dir);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package jaxx.demo.feature.validation;
import java.beans.*;
@@ -63,4 +83,4 @@
this.ratio = ratio;
p.firePropertyChange("ratio", oldRatio, ratio);
}
-}
\ No newline at end of file
+}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,325 +1,330 @@
-<jaxx.demo.DemoPanel>
- <style source="Validation.css"/>
-
-<script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-void $afterCompleteSetup() {
-}]]>
-</script>
- <!-- models -->
- <Model id='model1'/>
- <Model id='model2'/>
- <Identity id='identity'/>
-
- <!-- errors model -->
- <!-- Not existing :) -->
- <!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
- onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
-
- <!-- validators -->
- <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
- <field name="text"/>
- <field name="text2"/>
- <field name="ratio"/>
- </BeanValidator>
- <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
- <field name="text" component="_text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
- <BeanValidator id='validator3' autoField='true' bean='identity'
- uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
- <field name="email" component="email2"/>
- </BeanValidator>
-
- <Table fill='both' id='demoPanel'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='{model1.getText()}'
- _validatorLabel='{n_("form.text")}'
- onKeyReleased='model1.setText(text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text2' text='{model1.getText2()}'
- _validatorLabel='{n_("form.text2")}'
- onKeyReleased='model1.setText2(text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='ratio' minimum='0' maximum='100'
- value='{model1.getRatio()}'
- _validatorLabel='{n_("form.ratio")}'
- onStateChanged='model1.setRatio(ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model1.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- _validatorLabel='{n_("form2.text")}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- _validatorLabel='{n_("form2.text2")}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100'
- value='{model2.getRatio()}'
- _validatorLabel='{n_("form2.ratio")}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='180'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file :'/>
- </cell>
- <cell>
- <JTextField id='config' text='{identity.getConfig()}'
- onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Working directory:'/>
- </cell>
- <cell>
- <JTextField id='dir' text='{identity.getDir()}'
- onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getConfig()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Directory file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getDir()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
- width='500'>
- <JScrollPane>
- <JList id='errorList' model='{errors}'
- cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton id='cancel' text='cancel'
- onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- <JButton id='ok' text='valid'
- onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-
-</jaxx.demo.DemoPanel>
+<jaxx.demo.DemoPanel>
+ <style source="Validation.css"/>
+
+<script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+void $afterCompleteSetup() {
+}
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
+}
+]]>
+</script>
+ <!-- models -->
+ <Model id='model1'/>
+ <Model id='model2'/>
+ <Identity id='identity'/>
+
+ <!-- errors model -->
+ <!-- Not existing :) -->
+ <!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
+ onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
+ <field name="text" component="_text"/>
+ <field name="text2" component="_text2"/>
+ <field name="ratio" component="_ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator3' autoField='true' bean='identity'
+ uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
+ <field name="email" component="email2"/>
+ </BeanValidator>
+
+ <Table fill='both' id='demoPanel'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model1.getText()}'
+ _validatorLabel='{n_("form.text")}'
+ onKeyReleased='model1.setText(text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model1.getText2()}'
+ _validatorLabel='{n_("form.text2")}'
+ onKeyReleased='model1.setText2(text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model1.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
+ onKeyReleased='model2.setText(_text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
+ onKeyReleased='model2.setText2(_text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
+ onStateChanged='model2.setRatio(_ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model2.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
+ layout='{new GridLayout()}' width='250' height='180'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='firstName' text='{identity.getFirstName()}'
+ onKeyReleased='identity.setFirstName(firstName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='lastName' text='{identity.getLastName()}'
+ onKeyReleased='identity.setLastName(lastName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='email2' text='{identity.getEmail()}'
+ onKeyReleased='identity.setEmail(email2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
+ onStateChanged='identity.setAge(age.getValue())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file :'/>
+ </cell>
+ <cell>
+ <JTextField id='config' text='{identity.getConfig()}'
+ onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Working directory:'/>
+ </cell>
+ <cell>
+ <JTextField id='dir' text='{identity.getDir()}'
+ onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getFirstName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getLastName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getEmail()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getAge()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getConfig()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Directory file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getDir()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane>
+ <JList id='errorList' model='{errors}'
+ cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,331 +1,336 @@
-<jaxx.demo.DemoPanel>
- <style source="Validation.css"/>
-
- <!-- models -->
- <Model id='model1'/>
- <Model id='model2'/>
- <Identity id='identity'/>
-
- <!-- errors model -->
- <!-- Not existing :) -->
- <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
- onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
-
- <!-- validators -->
- <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
- <field name="text"/>
- <field name="text2"/>
- <field name="ratio"/>
- </BeanValidator>
- <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
- <field name="text" component="_text"/>
- <field name="text2" component="_text2"/>
- <field name="ratio" component="_ratio"/>
- </BeanValidator>
- <BeanValidator id='validator3' autoField='true' bean='identity'
- uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
- <field name="email" component="email2"/>
- </BeanValidator>
-
- <script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-import jaxx.runtime.SwingUtil;
-
-void $afterCompleteSetup() {
- jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
-}
-]]></script>
-
- <Table fill='both' id='demoPanel'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='{model1.getText()}'
- onKeyReleased='model1.setText(text.getText())'
- _validatorLabel='{n_("form.text")}'
- />
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text2' text='{model1.getText2()}'
- onKeyReleased='model1.setText2(text2.getText())'
- _validatorLabel='{n_("form.text2")}'
- />
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='ratio' minimum='0' maximum='100'
- value='{model1.getRatio()}'
- _validatorLabel='{n_("form.ratio")}'
- onStateChanged='model1.setRatio(ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model1.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model1.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text' text='{model2.getText()}'
- _validatorLabel='{n_("form2.text")}'
- onKeyReleased='model2.setText(_text.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='_text2' text='{model2.getText2()}'
- _validatorLabel='{n_("form2.text2")}'
- onKeyReleased='model2.setText2(_text2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JSlider id='_ratio' minimum='0' maximum='100'
- value='{model2.getRatio()}'
- _validatorLabel='{n_("form2.ratio")}'
- onStateChanged='model2.setRatio(_ratio.getValue())'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Text2:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{model2.getText2()}'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Ratio:'/>
- </cell>
- <cell>
- <JLabel text='{model2.getRatio()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
- layout='{new GridLayout()}' width='250' height='180'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='firstName' text='{identity.getFirstName()}'
- onKeyReleased='identity.setFirstName(firstName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='lastName' text='{identity.getLastName()}'
- onKeyReleased='identity.setLastName(lastName.getText())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='email2' text='{identity.getEmail()}'
- onKeyReleased='identity.setEmail(email2.getText())'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
- onStateChanged='identity.setAge(age.getValue())'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file :'/>
- </cell>
- <cell>
- <JTextField id='config' text='{identity.getConfig()}'
- onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Working directory:'/>
- </cell>
- <cell>
- <JTextField id='dir' text='{identity.getDir()}'
- onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
- layout='{new GridLayout()}' width='250' height='120'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='FirstName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getFirstName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='LastName:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getLastName()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Email:'/>
- </cell>
- <cell weightx='1'>
- <JLabel text='{identity.getEmail()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Age:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getAge()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Config file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getConfig()}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='Directory file:'/>
- </cell>
- <cell>
- <JLabel text='{identity.getDir()}'/>
- </cell>
- </row>
- </Table>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
- width='500'>
- <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true' autoCreateRowSorter='true'
- autoResizeMode='2' cellSelectionEnabled='false' selectionMode='0'/>
- </JScrollPane>
- </JPanel>
- </cell>
- </row>
- <row>
- <cell columns='2' fill="both">
- <JPanel layout='{new GridLayout(1,2,0,0)}'>
- <JButton id='cancel' text='cancel'
- onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- <JButton id='ok' text='valid'
- onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
- </JPanel>
- </cell>
- </row>
- </Table>
-
-</jaxx.demo.DemoPanel>
+<jaxx.demo.DemoPanel>
+ <style source="Validation.css"/>
+
+ <!-- models -->
+ <Model id='model1'/>
+ <Model id='model2'/>
+ <Identity id='identity'/>
+
+ <!-- errors model -->
+ <!-- Not existing :) -->
+ <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
+ <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
+ onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
+ <field name="text" component="_text"/>
+ <field name="text2" component="_text2"/>
+ <field name="ratio" component="_ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator3' autoField='true' bean='identity'
+ uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
+ <field name="email" component="email2"/>
+ </BeanValidator>
+
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.SwingUtil;
+
+void $afterCompleteSetup() {
+ jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
+}
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
+}
+]]></script>
+
+ <Table fill='both' id='demoPanel'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model1.getText()}'
+ onKeyReleased='model1.setText(text.getText())'
+ _validatorLabel='{n_("form.text")}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model1.getText2()}'
+ onKeyReleased='model1.setText2(text2.getText())'
+ _validatorLabel='{n_("form.text2")}'
+ />
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model1.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
+ onKeyReleased='model2.setText(_text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
+ onKeyReleased='model2.setText2(_text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
+ onStateChanged='model2.setRatio(_ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model2.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
+ layout='{new GridLayout()}' width='250' height='180'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='firstName' text='{identity.getFirstName()}'
+ onKeyReleased='identity.setFirstName(firstName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='lastName' text='{identity.getLastName()}'
+ onKeyReleased='identity.setLastName(lastName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='email2' text='{identity.getEmail()}'
+ onKeyReleased='identity.setEmail(email2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
+ onStateChanged='identity.setAge(age.getValue())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file :'/>
+ </cell>
+ <cell>
+ <JTextField id='config' text='{identity.getConfig()}'
+ onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Working directory:'/>
+ </cell>
+ <cell>
+ <JTextField id='dir' text='{identity.getDir()}'
+ onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getFirstName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getLastName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getEmail()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getAge()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getConfig()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Directory file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getDir()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true' autoCreateRowSorter='true'
+ autoResizeMode='2' cellSelectionEnabled='false' selectionMode='0'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,89 +1,95 @@
-<jaxx.demo.DemoPanel>
- <style source='Calculator.css'/>
- <script><![CDATA[
- plus.setText("+");
- sign.setText("+/-");
-]]></script>
- <!-- use fully-qualified name just in case this is compiled into a different package -->
- <CalculatorEngine id='engine'/>
-
- <Table id='demoPanel' fill='both'>
- <row>
- <cell columns='4'>
- <JLabel id='display' text='{engine.getDisplayText()}'/>
- </cell>
- </row>
-
- <row>
- <cell columns='2'>
- <JButton id='c' text='C' onActionPerformed='engine.clear()' styleClass='clear'/>
- </cell>
- <cell>
- <JButton id='ce' text='CE' onActionPerformed='engine.clearEntry()' styleClass='clear'/>
- </cell>
- <cell>
- <JButton id='equals' text='=' onActionPerformed='engine.equal()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d7' text='7' onActionPerformed='engine.digit(7)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d8' text='8' onActionPerformed='engine.digit(8)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d9' text='9' onActionPerformed='engine.digit(9)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='plus' onActionPerformed='engine.add()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d4' text='4' onActionPerformed='engine.digit(4)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d5' text='5' onActionPerformed='engine.digit(5)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d6' text='6' onActionPerformed='engine.digit(6)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='subtract' text='-' onActionPerformed='engine.subtract()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d1' text='1' onActionPerformed='engine.digit(1)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d2' text='2' onActionPerformed='engine.digit(2)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='d3' text='3' onActionPerformed='engine.digit(3)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='multiply' text='x' onActionPerformed='engine.multiply()' styleClass='operator'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JButton id='d0' text='0' onActionPerformed='engine.digit(0)' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='sign' onActionPerformed='engine.toggleSign()' styleClass='operator'/>
- </cell>
- <cell>
- <JButton id='dot' text='.' onActionPerformed='engine.dot()' styleClass='digit'/>
- </cell>
- <cell>
- <JButton id='divide' text='÷' onActionPerformed='engine.divide()' styleClass='operator'/>
- </cell>
- </row>
- </Table>
+<jaxx.demo.DemoPanel>
+ <style source='Calculator.css'/>
+ <script><![CDATA[
+ plus.setText("+");
+ sign.setText("+/-");
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Calculator.css", "CalculatorEngine.java" };
+}
+]]>
+ </script>
+ <!-- use fully-qualified name just in case this is compiled into a different package -->
+ <CalculatorEngine id='engine'/>
+
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell columns='4'>
+ <JLabel id='display' text='{engine.getDisplayText()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2'>
+ <JButton id='c' text='C' onActionPerformed='engine.clear()' styleClass='clear'/>
+ </cell>
+ <cell>
+ <JButton id='ce' text='CE' onActionPerformed='engine.clearEntry()' styleClass='clear'/>
+ </cell>
+ <cell>
+ <JButton id='equals' text='=' onActionPerformed='engine.equal()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d7' text='7' onActionPerformed='engine.digit(7)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d8' text='8' onActionPerformed='engine.digit(8)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d9' text='9' onActionPerformed='engine.digit(9)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='plus' onActionPerformed='engine.add()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d4' text='4' onActionPerformed='engine.digit(4)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d5' text='5' onActionPerformed='engine.digit(5)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d6' text='6' onActionPerformed='engine.digit(6)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='subtract' text='-' onActionPerformed='engine.subtract()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d1' text='1' onActionPerformed='engine.digit(1)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d2' text='2' onActionPerformed='engine.digit(2)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d3' text='3' onActionPerformed='engine.digit(3)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='multiply' text='x' onActionPerformed='engine.multiply()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d0' text='0' onActionPerformed='engine.digit(0)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='sign' onActionPerformed='engine.toggleSign()' styleClass='operator'/>
+ </cell>
+ <cell>
+ <JButton id='dot' text='.' onActionPerformed='engine.dot()' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='divide' text='÷' onActionPerformed='engine.divide()' styleClass='operator'/>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,177 +1,197 @@
-package jaxx.demo.fun;
-
-import java.beans.*;
-import java.math.*;
-
-public class CalculatorEngine {
- public static final String DISPLAY_TEXT_PROPERTY = "displayText";
-
- public static final int ADD = 0;
- public static final int SUBTRACT = 1;
- public static final int MULTIPLY = 2;
- public static final int DIVIDE = 3;
- public static final int RESULT = 4;
-
- private int operation = -1;
- private boolean clear = true; // true to clear on next key
- private String displayText = "0";
- private BigDecimal value;
- private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
-
-
- public String getDisplayText() {
- return displayText;
- }
-
-
- public void setDisplayText(String displayText) {
- String oldDisplayText = this.displayText;
- this.displayText = displayText;
- firePropertyChange(DISPLAY_TEXT_PROPERTY, oldDisplayText, displayText);
- }
-
-
- public void clear() {
- clearEntry();
- value = new BigDecimal(0);
- operation = -1;
- }
-
-
- public void clearEntry() {
- setDisplayText("0");
- clear = true;
- }
-
-
- private void checkClear() {
- if (clear) {
- setDisplayText("");
- clear = false;
- }
- }
-
-
- public void digit(int digit) {
- checkClear();
- setDisplayText(getDisplayText() + String.valueOf(digit));
- }
-
-
- public void dot() {
- checkClear();
- if (getDisplayText().indexOf('.') == -1) {
- if (getDisplayText().length() == 0) {
- setDisplayText("0.");
- } else {
- setDisplayText(getDisplayText() + '.');
- }
- }
- }
-
-
- public void toggleSign() {
- String text = getDisplayText();
- if (text.startsWith("-")) {
- text = text.substring(1);
- } else if (!text.equals("0")) {
- text = '-' + text;
- }
- setDisplayText(text);
- }
-
-
- public void equal() {
- BigDecimal displayValue = new BigDecimal(getDisplayText());
- BigDecimal newValue = displayValue;
- switch (operation) {
- case ADD:
- newValue = value.add(displayValue);
- break;
- case SUBTRACT:
- newValue = value.subtract(displayValue);
- break;
- case MULTIPLY:
- newValue = value.multiply(displayValue);
- break;
- case DIVIDE:
- newValue = value.divide(displayValue, 8, BigDecimal.ROUND_HALF_UP);
- break;
- }
- value = newValue;
- setDisplayText(toString(newValue));
- clear = true;
- operation = -1;
- }
-
-
- public static String toString(BigDecimal decimal) {
- // can't use stripTrailingZeros, as it wasn't introduced until 1.5
- String result = decimal.toString();
- if (result.indexOf(".") != -1) {
- while (result.endsWith("0")) {
- result = result.substring(0, result.length() - 1);
- }
- if (result.endsWith(".")) {
- result = result.substring(0, result.length() - 1);
- }
- }
- return result;
- }
-
-
- public void operation(int operation) {
- if (this.operation != -1) {
- equal();
- } else {
- value = new BigDecimal(getDisplayText());
- clear = true;
- }
- this.operation = operation;
- }
-
-
- public void add() {
- operation(ADD);
- }
-
-
- public void subtract() {
- operation(SUBTRACT);
- }
-
-
- public void multiply() {
- operation(MULTIPLY);
- }
-
-
- public void divide() {
- operation(DIVIDE);
- }
-
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(listener);
- }
-
-
- public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
- propertyChangeSupport.addPropertyChangeListener(property, listener);
- }
-
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(listener);
- }
-
-
- public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
- propertyChangeSupport.removePropertyChangeListener(property, listener);
- }
-
-
- protected void firePropertyChange(String property, Object oldValue, Object newValue) {
- propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
- }
-}
\ No newline at end of file
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.demo.fun;
+
+import java.beans.*;
+import java.math.*;
+
+public class CalculatorEngine {
+ public static final String DISPLAY_TEXT_PROPERTY = "displayText";
+
+ public static final int ADD = 0;
+ public static final int SUBTRACT = 1;
+ public static final int MULTIPLY = 2;
+ public static final int DIVIDE = 3;
+ public static final int RESULT = 4;
+
+ private int operation = -1;
+ private boolean clear = true; // true to clear on next key
+ private String displayText = "0";
+ private BigDecimal value;
+ private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+
+ public void setDisplayText(String displayText) {
+ String oldDisplayText = this.displayText;
+ this.displayText = displayText;
+ firePropertyChange(DISPLAY_TEXT_PROPERTY, oldDisplayText, displayText);
+ }
+
+
+ public void clear() {
+ clearEntry();
+ value = new BigDecimal(0);
+ operation = -1;
+ }
+
+
+ public void clearEntry() {
+ setDisplayText("0");
+ clear = true;
+ }
+
+
+ private void checkClear() {
+ if (clear) {
+ setDisplayText("");
+ clear = false;
+ }
+ }
+
+
+ public void digit(int digit) {
+ checkClear();
+ setDisplayText(getDisplayText() + String.valueOf(digit));
+ }
+
+
+ public void dot() {
+ checkClear();
+ if (getDisplayText().indexOf('.') == -1) {
+ if (getDisplayText().length() == 0) {
+ setDisplayText("0.");
+ } else {
+ setDisplayText(getDisplayText() + '.');
+ }
+ }
+ }
+
+
+ public void toggleSign() {
+ String text = getDisplayText();
+ if (text.startsWith("-")) {
+ text = text.substring(1);
+ } else if (!text.equals("0")) {
+ text = '-' + text;
+ }
+ setDisplayText(text);
+ }
+
+
+ public void equal() {
+ BigDecimal displayValue = new BigDecimal(getDisplayText());
+ BigDecimal newValue = displayValue;
+ switch (operation) {
+ case ADD:
+ newValue = value.add(displayValue);
+ break;
+ case SUBTRACT:
+ newValue = value.subtract(displayValue);
+ break;
+ case MULTIPLY:
+ newValue = value.multiply(displayValue);
+ break;
+ case DIVIDE:
+ newValue = value.divide(displayValue, 8, BigDecimal.ROUND_HALF_UP);
+ break;
+ }
+ value = newValue;
+ setDisplayText(toString(newValue));
+ clear = true;
+ operation = -1;
+ }
+
+
+ public static String toString(BigDecimal decimal) {
+ // can't use stripTrailingZeros, as it wasn't introduced until 1.5
+ String result = decimal.toString();
+ if (result.indexOf(".") != -1) {
+ while (result.endsWith("0")) {
+ result = result.substring(0, result.length() - 1);
+ }
+ if (result.endsWith(".")) {
+ result = result.substring(0, result.length() - 1);
+ }
+ }
+ return result;
+ }
+
+
+ public void operation(int operation) {
+ if (this.operation != -1) {
+ equal();
+ } else {
+ value = new BigDecimal(getDisplayText());
+ clear = true;
+ }
+ this.operation = operation;
+ }
+
+
+ public void add() {
+ operation(ADD);
+ }
+
+
+ public void subtract() {
+ operation(SUBTRACT);
+ }
+
+
+ public void multiply() {
+ operation(MULTIPLY);
+ }
+
+
+ public void divide() {
+ operation(DIVIDE);
+ }
+
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(listener);
+ }
+
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(property, listener);
+ }
+
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(listener);
+ }
+
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(property, listener);
+ }
+
+
+ protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+ propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
+ }
+}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-04 08:57:25 UTC (rev 1555)
@@ -1,85 +1,92 @@
-<jaxx.demo.DemoPanel>
- <style source="LabelStyle.css"/>
-
- <Table id='demoPanel' anchor='north' fill='both'>
- <row>
- <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
- <Table anchor='west' fill='both'>
- <row>
- <cell>
- <JLabel text='Text:'/>
- </cell>
- <cell weightx='1'>
- <JTextField id='text' text='Data Binding'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Red:'/>
- </cell>
- <cell>
- <JSlider id='red' value='128' maximum='255' styleClass='color'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Green:'/>
- </cell>
- <cell>
- <JSlider id='green' value='0' maximum='255' styleClass='color'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Blue:'/>
- </cell>
- <cell>
- <JSlider id='blue' value='255' maximum='255' styleClass='color'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JLabel text='Size:'/>
- </cell>
- <cell>
- <JSlider id='dummySize' value='36' minimum='6' maximum='60'/>
- </cell>
- </row>
-
- <row>
- <cell columns='2' fill='both' weighty='1'>
- <JPanel border='{BorderFactory.createTitledBorder("Preview")}'
- height='90'
- layout='{new BorderLayout()}'>
- <VBox background='{(Color)( backgroundCheckbox.isSelected() ? backgroundColor.getSelectedValue() : null)}'
- margin='0'
- horizontalAlignment='center'
- verticalAlignment='middle'>
- <JLabel text='{text.getText()}' font-size='{dummySize.getValue()}'
- foreground='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/>
- </VBox>
- </JPanel>
- </cell>
- </row>
- </Table>
- </cell>
-
- <cell>
- <VBox spacing='0' border='{BorderFactory.createTitledBorder("Background")}'>
- <JCheckBox id='backgroundCheckbox' text='Show Background'/>
- <JRadioButton text='Red' buttonGroup='backgroundColor' value='{Color.RED}' selected='true'/>
- <JRadioButton text='Orange' buttonGroup='backgroundColor' value='{Color.ORANGE}'/>
- <JRadioButton text='Yellow' buttonGroup='backgroundColor' value='{Color.YELLOW}'/>
- <JRadioButton text='Green' buttonGroup='backgroundColor' value='{Color.GREEN}'/>
- <JRadioButton text='Cyan' buttonGroup='backgroundColor' value='{Color.CYAN}'/>
- <JRadioButton text='Blue' buttonGroup='backgroundColor' value='{Color.BLUE}'/>
- <JRadioButton text='Purple' buttonGroup='backgroundColor' value='{new Color(160, 30, 255)}'/>
- </VBox>
- </cell>
- </row>
- </Table>
+<jaxx.demo.DemoPanel>
+ <style source="LabelStyle.css"/>
+ <script><![CDATA[
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "LabelStyle.css" };
+}
+
+]]>
+ </script>
+ <Table id='demoPanel' anchor='north' fill='both'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='Data Binding'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Red:'/>
+ </cell>
+ <cell>
+ <JSlider id='red' value='128' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Green:'/>
+ </cell>
+ <cell>
+ <JSlider id='green' value='0' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Blue:'/>
+ </cell>
+ <cell>
+ <JSlider id='blue' value='255' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Size:'/>
+ </cell>
+ <cell>
+ <JSlider id='dummySize' value='36' minimum='6' maximum='60'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2' fill='both' weighty='1'>
+ <JPanel border='{BorderFactory.createTitledBorder("Preview")}'
+ height='90'
+ layout='{new BorderLayout()}'>
+ <VBox background='{(Color)( backgroundCheckbox.isSelected() ? backgroundColor.getSelectedValue() : null)}'
+ margin='0'
+ horizontalAlignment='center'
+ verticalAlignment='middle'>
+ <JLabel text='{text.getText()}' font-size='{dummySize.getValue()}'
+ foreground='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/>
+ </VBox>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+
+ <cell>
+ <VBox spacing='0' border='{BorderFactory.createTitledBorder("Background")}'>
+ <JCheckBox id='backgroundCheckbox' text='Show Background'/>
+ <JRadioButton text='Red' buttonGroup='backgroundColor' value='{Color.RED}' selected='true'/>
+ <JRadioButton text='Orange' buttonGroup='backgroundColor' value='{Color.ORANGE}'/>
+ <JRadioButton text='Yellow' buttonGroup='backgroundColor' value='{Color.YELLOW}'/>
+ <JRadioButton text='Green' buttonGroup='backgroundColor' value='{Color.GREEN}'/>
+ <JRadioButton text='Cyan' buttonGroup='backgroundColor' value='{Color.CYAN}'/>
+ <JRadioButton text='Blue' buttonGroup='backgroundColor' value='{Color.BLUE}'/>
+ <JRadioButton text='Purple' buttonGroup='backgroundColor' value='{new Color(160, 30, 255)}'/>
+ </VBox>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-04 08:57:25 UTC (rev 1555)
@@ -73,6 +73,7 @@
Sign\ on=
Simple\ Button=
Size\:=
+Sources=
Spacing\:=
Start=
Stop=
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-04 08:25:09 UTC (rev 1554)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-04 08:57:25 UTC (rev 1555)
@@ -73,6 +73,7 @@
Sign\ on=Signer
Simple\ Button=Bouton simple
Size\:=Taille \:
+Sources=Sources
Spacing\:=Espacement \:
Start=D\u00E9marrer
Stop=Arr\u00EAter
1
0
Author: tchemit
Date: 2009-10-04 10:25:09 +0200 (Sun, 04 Oct 2009)
New Revision: 1554
Modified:
trunk/jaxx-demo/pom.xml
Log:
fix websatrt config + readd sources in class-path (demo shows them)
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2009-10-03 23:22:44 UTC (rev 1553)
+++ trunk/jaxx-demo/pom.xml 2009-10-04 08:25:09 UTC (rev 1554)
@@ -85,6 +85,12 @@
<include>**/*</include>
</includes>
</resource>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
</resources>
<pluginManagement>
@@ -247,27 +253,17 @@
<artifactId>maven-helper-plugin</artifactId>
<executions>
<execution>
- <id>get-jnlp-keystore</id>
+ <id>get-keystore</id>
<goals>
<goal>share-server-secret</goal>
</goals>
<phase>package</phase>
<configuration>
<serverId>codelutin-keystore</serverId>
- <usernameOut>keystorepath</usernameOut>
+ <privateKeyOut>keystorepath</privateKeyOut>
<passwordOut>keystorepass</passwordOut>
- </configuration>
- </execution>
- <execution>
- <id>get-jnlp-key</id>
- <goals>
- <goal>share-server-secret</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <serverId>codelutin-keystore-nuiton-key</serverId>
<usernameOut>keyalias</usernameOut>
- <passwordOut>keypass</passwordOut>
+ <passphraseOut>keypass</passphraseOut>
</configuration>
</execution>
</executions>
1
0
Author: tchemit
Date: 2009-10-04 01:22:44 +0200 (Sun, 04 Oct 2009)
New Revision: 1553
Modified:
trunk/pom.xml
Log:
Evolution #72: am?\195?\169lioration de Jaxx demo (creation du module jaxx-demo)
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-10-03 23:10:18 UTC (rev 1552)
+++ trunk/pom.xml 2009-10-03 23:22:44 UTC (rev 1553)
@@ -27,7 +27,9 @@
<module>jaxx-runtime-swing-widget</module>
- <module>jaxx-example</module>
+ <!-- deprecated since 1.7.2, will be removed before 2.0.0
+ <module>jaxx-example</module-->
+ <module>jaxx-demo</module>
</modules>
<dependencyManagement>
1
0
Author: tchemit
Date: 2009-10-04 01:10:18 +0200 (Sun, 04 Oct 2009)
New Revision: 1552
Added:
trunk/jaxx-demo/
trunk/jaxx-demo/LICENSE.txt
trunk/jaxx-demo/README.txt
trunk/jaxx-demo/changelog.txt
trunk/jaxx-demo/pom.xml
trunk/jaxx-demo/src/
trunk/jaxx-demo/src/main/
trunk/jaxx-demo/src/main/filters/
trunk/jaxx-demo/src/main/filters/jaxx-demo.properties
trunk/jaxx-demo/src/main/java/
trunk/jaxx-demo/src/main/java/jaxx/
trunk/jaxx-demo/src/main/java/jaxx/demo/
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Validation.css
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
trunk/jaxx-demo/src/main/resources/
trunk/jaxx-demo/src/main/resources/i18n/
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
trunk/jaxx-demo/src/main/resources/icons/
trunk/jaxx-demo/src/main/resources/icons/action-about.png
trunk/jaxx-demo/src/main/resources/icons/action-accept.png
trunk/jaxx-demo/src/main/resources/icons/action-block.png
trunk/jaxx-demo/src/main/resources/icons/action-close.png
trunk/jaxx-demo/src/main/resources/icons/action-config.png
trunk/jaxx-demo/src/main/resources/icons/action-exit.png
trunk/jaxx-demo/src/main/resources/icons/action-fullscreen.png
trunk/jaxx-demo/src/main/resources/icons/action-help.png
trunk/jaxx-demo/src/main/resources/icons/action-i18n-fr.png
trunk/jaxx-demo/src/main/resources/icons/action-i18n-uk.png
trunk/jaxx-demo/src/main/resources/icons/action-leave-fullscreen.png
trunk/jaxx-demo/src/main/resources/icons/action-show-help.png
trunk/jaxx-demo/src/main/resources/icons/action-site.png
trunk/jaxx-demo/src/main/resources/icons/action-translate.png
trunk/jaxx-demo/src/main/resources/icons/jaxx.png
trunk/jaxx-demo/src/main/resources/jaxx/
trunk/jaxx-demo/src/main/resources/jaxx/demo/
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-error-validation.xml
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-info-validation.xml
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-warning-validation.xml
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-error-validation.xml
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-info-validation.xml
trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-warning-validation.xml
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Amethyst.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Lynx.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Tomato.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/ana.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/hector.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/jack.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/joe.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/nacho.jpg
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/nacho2.png
trunk/jaxx-demo/src/main/resources/jaxx/demo/images/pencil_black.gif
trunk/jaxx-demo/src/main/resources/log4j.properties
trunk/jaxx-demo/src/site/
trunk/jaxx-demo/src/site/rst/
trunk/jaxx-demo/src/site/rst/images/
trunk/jaxx-demo/src/site/rst/images/Components-screenshot.gif
trunk/jaxx-demo/src/site/rst/images/webstart.gif
trunk/jaxx-demo/src/site/rst/index.rst
trunk/jaxx-demo/src/site/site.xml
trunk/jaxx-demo/src/test/
trunk/jaxx-demo/src/test/java/
trunk/jaxx-demo/src/test/java/jaxx/
trunk/jaxx-demo/src/test/java/jaxx/demo/
trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java
trunk/jaxx-demo/src/test/resources/
Log:
Evolution #72: am?\195?\169lioration de Jaxx demo (creation du module jaxx-demo)
Property changes on: trunk/jaxx-demo
___________________________________________________________________
Added: svn:ignore
+ target
Added: trunk/jaxx-demo/LICENSE.txt
===================================================================
--- trunk/jaxx-demo/LICENSE.txt (rev 0)
+++ trunk/jaxx-demo/LICENSE.txt 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: trunk/jaxx-demo/README.txt
===================================================================
--- trunk/jaxx-demo/README.txt (rev 0)
+++ trunk/jaxx-demo/README.txt 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: trunk/jaxx-demo/changelog.txt
===================================================================
--- trunk/jaxx-demo/changelog.txt (rev 0)
+++ trunk/jaxx-demo/changelog.txt 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,2 @@
+1.7.2
+ * 20091003 [chemit] - initial release (insparated from obsolote jaxx-example module)
Added: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml (rev 0)
+++ trunk/jaxx-demo/pom.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,296 @@
+
+<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.nuiton</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.7.2-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.jaxx</groupId>
+ <artifactId>jaxx-demo</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>
+
+ <!-- test dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-api</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <classifier>tests</classifier>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx Demo module</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <maven.jar.main.class>jaxx.demo.RunDemo</maven.jar.main.class>
+
+ <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath>
+ <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>
+ </properties>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/filters</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>jaxx-demo.properties</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>
+
+ <plugin>
+ <groupId>org.nuiton.thirdparty</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <configuration>
+ <jnlpExtensions>
+ <jnlpExtension>
+ <name>sun</name>
+ <title>Sun MicroSystems</title>
+ <vendor>Sun MicroSystems, Inc.</vendor>
+ <includes>
+ <include>javax.help:javahelp</include>
+ </includes>
+ </jnlpExtension>
+ <jnlpExtension>
+ <name>jxlayer</name>
+ <title>Swing labs JXLayer </title>
+ <vendor>Swing Labs</vendor>
+ <includes>
+ <include>org.swinglabs:jxlayer</include>
+ </includes>
+ </jnlpExtension>
+ </jnlpExtensions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-helper-plugin</artifactId>
+ <configuration>
+ <copyToMETA_INF>true</copyToMETA_INF>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-licenses</id>
+ <goals>
+ <goal>add-license</goal>
+ <goal>add-third-party</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+
+ </pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java/</basedir>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ <overWriteIfNewer>true</overWriteIfNewer>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ <silent>true</silent>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-helper-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-licenses</id>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.thirdparty</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <version>1.0-alpha-2-cl_20091001</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <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>
+ <!-- key store secrets availables -->
+ <plugin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-helper-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>get-jnlp-keystore</id>
+ <goals>
+ <goal>share-server-secret</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <serverId>codelutin-keystore</serverId>
+ <usernameOut>keystorepath</usernameOut>
+ <passwordOut>keystorepass</passwordOut>
+ </configuration>
+ </execution>
+ <execution>
+ <id>get-jnlp-key</id>
+ <goals>
+ <goal>share-server-secret</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <serverId>codelutin-keystore-nuiton-key</serverId>
+ <usernameOut>keyalias</usernameOut>
+ <passwordOut>keypass</passwordOut>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- make webstart -->
+ <plugin>
+ <groupId>org.nuiton.thirdparty</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-jnlp</id>
+ <phase>package</phase>
+ <goals>
+ <goal>jnlp-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ </profiles>
+
+</project>
Added: trunk/jaxx-demo/src/main/filters/jaxx-demo.properties
===================================================================
--- trunk/jaxx-demo/src/main/filters/jaxx-demo.properties (rev 0)
+++ trunk/jaxx-demo/src/main/filters/jaxx-demo.properties 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,7 @@
+application.name=${project.name}
+application.version=${project.version}
+application.site.url=http://maven-site.nuiton.org/jaxx/jaxx-example
+#licence.name=${project.licenses[0].license.name}
+#licence.url=${project.licenses.0.url}
+application.organisation.name=${project.organization.name}
+application.organisation.url=${project.organization.url}
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,189 @@
+package jaxx.demo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.beans.PropertyChangeListener;
+import java.util.Locale;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.nuiton.util.Version;
+import org.nuiton.util.VersionUtil;
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * La configuration de l'application.
+ *
+ * Il s'agit de l'objet partagé par toutes les démos.
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class DemoConfig extends org.nuiton.util.ApplicationConfig {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(DemoConfig.class);
+ /**
+ * le fichier de configuration de l'application avec les informations sur
+ * le projet (version, license,...) et la configuration des ui (icons, ...)
+ */
+ public static final String APPLICATION_PROPERTIES = "/jaxx-demo.properties";
+ /**
+ * un drapeau pour savoir si on est en mode pleine écran
+ */
+ protected boolean fullscreen;
+
+ public DemoConfig() {
+
+ setConfigFileName(Option.CONFIG_FILE.defaultValue);
+
+ // chargement de la configuration interne
+
+ InputStream stream = getClass().getResourceAsStream(APPLICATION_PROPERTIES);
+
+ Properties p = new Properties();
+ try {
+ p.load(stream);
+ for (Object k : p.keySet()) {
+ String key = k + "";
+ Object value = p.get(k);
+ if (log.isDebugEnabled()) {
+ log.debug("install properties " + k + " : " + value);
+ }
+ setDefaultOption(key, "" + value);
+ }
+ } catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+
+ for (Option o : Option.values()) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+
+ // on supprime le stamp de snapshot s'il existe
+ String sVersion = VersionUtil.removeSnapshot(getOption("application.version"));
+ Version version = VersionUtil.valueOf(sVersion);
+ setDefaultOption("version", version.getVersion());
+ }
+
+ public String getCopyrightText() {
+ return "Version " + getVersion() + " Codelutin @ 2008-2009";
+ }
+
+ /**
+ * @return la version de l'application.
+ */
+ public Version getVersion() {
+ Version option = getOption(Version.class, "version");
+ return option;
+ }
+
+ public boolean isFullScreen() {
+ Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
+ }
+
+ public Locale getLocale() {
+ Locale result = getOption(Locale.class, Option.LOCALE.key);
+ return result;
+ }
+
+ public void setFullscreen(boolean fullscreen) {
+ Object oldValue = null;
+ setOption(Option.FULL_SCREEN.key, fullscreen + "");
+ saveForUser();
+ firePropertyChange("fullscreen", oldValue, fullscreen);
+ }
+
+ public void setLocale(Locale newLocale) {
+ setOption(Option.LOCALE.key, newLocale.toString());
+ saveForUser();
+ firePropertyChange("locale", null, newLocale);
+ }
+
+ /**
+ * Save configuration, in user home directory using the
+ * {@link #getConfigFileName}. Default, env and commande line note saved
+ */
+ public void saveForUser() {
+ // shoudl we never save any conf ?
+ super.saveForUser();
+ }
+ public static final String[] DEFAULT_JAXX_PCS = {
+ "fullScreen", "locale"
+ };
+
+ public void removeJaxxPropertyChangeListener() {
+ PropertyChangeListener[] toRemove = jaxx.runtime.Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ if (toRemove == null || toRemove.length == 0) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("before remove : " + getPropertyChangeListeners().length);
+ log.debug("toRemove : " + toRemove.length);
+ }
+ for (PropertyChangeListener listener : toRemove) {
+ removePropertyChangeListener(listener);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("after remove : " + getPropertyChangeListeners().length);
+ }
+ }
+
+ //////////////////////////////////////////////////
+ // Toutes les options disponibles
+ //////////////////////////////////////////////////
+ public static enum Option implements OptionDef {
+
+ CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
+ FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui.locale", _("jaxxdemo.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false);
+ public final String key;
+ public final String description;
+ public final String defaultValue;
+ public final Class<?> type;
+ public final boolean _transient;
+ public final boolean _final;
+
+ private Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,73 @@
+<JTabbedPane id='top'>
+
+ <script><![CDATA[
+ import java.io.*;
+
+ public DemoPanel(String... extraSources) {
+ super();
+
+ for (String extra : extraSources) {
+ // creation du contenu du fichier
+ JTextArea content = new JTextArea();
+ content.setEditable(false);
+ content.setText(loadSource(extra));
+ // ajout de l'onglet
+ top.addTab(extra,null,content,null);
+ }
+ }
+
+ public String getLabel() {
+ String name = getClass().getName();
+ name = name.substring(name.lastIndexOf(".") + 1);
+ if (name.endsWith("Demo"))
+ name = name.substring(0, name.length() - "Demo".length());
+ return name;
+ }
+
+
+ public String getDemoTabTitle() {
+ return getLabel() + " Demo";
+ }
+
+ public String loadSource(String filename) {
+ try {
+ Reader in = new InputStreamReader(getClass().getResourceAsStream(filename));
+ StringWriter out = new StringWriter();
+ char[] buffer = new char[2048];
+ int c;
+ while ((c = in.read(buffer)) > 0)
+ out.write(buffer, 0, c);
+ return out.toString();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String loadSource() {
+ try {
+ String className = getClass().getName();
+ Reader in = new InputStreamReader(getClass().getResourceAsStream(className.substring(className.lastIndexOf(".") + 1) + ".jaxx"));
+ StringWriter out = new StringWriter();
+ char[] buffer = new char[2048];
+ int c;
+ while ((c = in.read(buffer)) > 0)
+ out.write(buffer, 0, c);
+ return out.toString();
+ }
+ catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ ]]></script>
+
+ <tab title='{getDemoTabTitle()}'>
+ <JPanel id='demoPanel'/>
+ </tab>
+
+ <!--tab title='Source'>
+ <JScrollPane height='100'>
+ <JTextArea text='{loadSource()}' editable='false'/>
+ </JScrollPane>
+ </tab-->
+</JTabbedPane>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,205 @@
+package jaxx.demo;
+
+import java.util.Stack;
+import javax.swing.JPanel;
+import jaxx.demo.component.swing.*;
+import jaxx.demo.component.jaxx.*;
+import jaxx.demo.component.jaxx.editor.*;
+import jaxx.demo.component.jaxx.navigation.full.FullNavigationTreeDemo;
+import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
+import jaxx.demo.feature.databinding.BeanDataBindingDemo;
+import jaxx.demo.feature.validation.*;
+import jaxx.demo.fun.*;
+
+import static org.nuiton.i18n.I18n.n_;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
+import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ */
+public class DemoTreeHelper extends NavigationTreeHelper {
+
+ static private final Log log = LogFactory.getLog(DemoTreeHelper.class);
+
+ public DemoTreeHelper() {
+ super("demo");
+ }
+
+ @Override
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("start creating demo model");
+ }
+
+ TreeModelBuilder builder = new TreeModelBuilder();
+
+ builder.addText(n_("jaxxdemo.tree.component.swing")).
+ addText(n_("jaxxdemo.tree.component.swing.buttons")).
+ addDemo(JButtonDemo.class).
+ addDemo(JCheckBoxDemo.class).
+ addDemo(JRadioButtonDemo.class).
+ addDemo(JToggleButtonDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.component.swing.form")).
+ addText(n_("jaxxdemo.tree.component.swing.form.text")).
+ addDemo(JPasswordFieldDemo.class).
+ addDemo(JTextFieldDemo.class).
+ addDemo(JTextAreaDemo.class).
+ goUp().
+ addDemo(JComboBoxDemo.class).
+ addDemo(JListDemo.class).
+ addDemo(JSliderDemo.class).
+ addDemo(JSpinnerDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.component.swing.layout")).
+ addDemo(JSplitPaneDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.component.swing.menu")).
+ addDemo(JMenuItemDemo.class).
+ addDemo(JCheckBoxMenuItemDemo.class).
+ addDemo(JRadioButtonMenuItemDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.component.swing.window")).
+ addDemo(JDialogDemo.class).
+ goUp().
+ addDemo(JProgressBarDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.component.jaxx")).
+ addText(n_("jaxxdemo.tree.component.jaxx.editor")).
+ addDemo(NumberEditorDemo.class).
+ addDemo(ComboEditorDemo.class).
+ addDemo(I18nEditorDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.component.jaxx.tree.navigation")).
+ addDemo(ItemTreeNavigationDemo.class).
+ addDemo(FullNavigationTreeDemo.class).
+ goUp().
+ addDemo(BoxedDecoratorDemo.class).
+ addDemo(StatusMessagePanelDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.feature")).
+ addText(n_("jaxxdemo.tree.features.databinding")).
+ addDemo(BeanDataBindingDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.features.validation")).
+ addDemo(ValidationListDemo.class).
+ addDemo(ValidationTableDemo.class).
+ goUp().
+ addText(n_("jaxxdemo.tree.fun")).
+ addDemo(LabelStyleDemo.class).
+ addDemo(CounterDemo.class).
+ addDemo(CalculatorDemo.class);
+
+ NavigationTreeModel model = builder.getModel();
+
+ if (log.isDebugEnabled()) {
+ builder.printModel(context, model.getRoot());
+ }
+ // save tree model in context
+ setTreeModel(context, model);
+ return model;
+ }
+
+ @Override
+ public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+
+ NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout(
+ getPrefix(),
+ DemoPanel.class,
+ null,
+ context,
+ Strategy.PER_UI_TYPE) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected NavigationTreeModel getNavigationTreeModel() {
+ return getTreeModel(getContext());
+ }
+
+ @Override
+ protected JPanel getContentContainer() {
+ return getContext().getContent();
+ }
+
+ @Override
+ protected CardLayout2 getContentLayout() {
+ return getContext().getContentLayout();
+ }
+
+ @Override
+ protected void treateError(Exception e) {
+ ErrorDialogUI.showError(e);
+ }
+
+ protected DemoUI getContext() {
+ return (DemoUI) context;
+ }
+ };
+ // on ne peut selectionner qu'un seul noeud a la fois
+ handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+
+ // save handler in ui context
+ setTreeHandler(context, handler);
+ return handler;
+ }
+
+ static class TreeModelBuilder extends NavigationTreeModelBuilder {
+
+ /**
+ * la definition de l'unqiue object a partage
+ */
+ static private final JAXXContextEntryDef<DemoConfig> def = JAXXContextEntryDef.newDef(DemoConfig.class);
+ /**
+ * la pile des noeuds parent
+ */
+ protected Stack<NavigationTreeNode> parentNodes;
+
+ protected TreeModelBuilder() {
+ super("/");
+ parentNodes = new Stack<NavigationTreeNode>();
+ parentNodes.add(buildEmptyRoot(def, "$root"));
+ }
+
+ protected TreeModelBuilder goUp() {
+ parentNodes.pop();
+ return this;
+ }
+
+ protected TreeModelBuilder addText(String label) {
+ NavigationTreeNode parentNode = parentNodes.peek();
+ parentNode = build(parentNode, label, def, label, null, null);
+ if (log.isDebugEnabled()) {
+ log.debug(label + " [" + parentNode.getContextPath() + "]");
+ }
+ parentNodes.push(parentNode);
+ return this;
+ }
+
+ protected TreeModelBuilder addDemo(Class<? extends DemoPanel> demoClass) {
+ NavigationTreeNode parentNode = parentNodes.peek();
+ String label = demoClass.getSimpleName();
+ if (log.isDebugEnabled()) {
+ log.debug(label + " [" + parentNode.getContextPath() + "]");
+ }
+ build(parentNode, label, def, label, demoClass, null);
+ return this;
+ }
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,164 @@
+/**
+ * *##% observe-swing
+ * Copyright (C) 2008 - 2009 IRD
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
+ */
+JToolBar {
+ borderPainted:false;
+ floatable:false;
+ opaque:false;
+}
+
+JSplitPane {
+ oneTouchExpandable:true;
+ continuousLayout:true;
+ dividerSize:6;
+}
+
+#menu {
+ _help:{"ui.main.menu"};
+}
+
+#menuFile {
+ text:"jaxxdemo.menu.file";
+ mnemonic:F;
+ _help:{"ui.main.menu.file"};
+}
+
+#menuFileConfiguration {
+ text:"jaxxdemo.action.configuration";
+ toolTipText:"jaxxdemo.action.configuration.tip";
+ actionIcon:"config";
+ mnemonic:C;
+ enabled:false;
+ _help:{"ui.main.menu.file.configuration"};
+}
+
+#menuFileLanguage {
+ text:"jaxxdemo.menu.file.locale";
+ toolTipText:"jaxxdemo.menu.file.locale";
+ actionIcon:"translate";
+ mnemonic:C;
+ _help:{"ui.main.menu.file.locale"};
+}
+
+
+#menuFileLanguageFR {
+ text:"jaxxdemo.action.locale.fr";
+ toolTipText:"jaxxdemo.action.locale.fr.tip";
+ actionIcon:"i18n-fr";
+ enabled:{!acceptLocale(getConfig().getLocale(), "fr_FR")};
+ mnemonic:F;
+ _help:{"ui.main.menu.file.locale.fr"};
+}
+
+#menuFileLanguageUK {
+ text:"jaxxdemo.action.locale.uk";
+ toolTipText:"jaxxdemo.action.locale.uk.tip";
+ actionIcon:"i18n-uk";
+ enabled:{!acceptLocale(getConfig().getLocale(), "en_GB")};
+ mnemonic:U;
+ _help:{"ui.main.menu.file.locale.uk"};
+}
+
+#menuFileFullscreen {
+ text:"jaxxdemo.action.fullscreen";
+ toolTipText:"jaxxdemo.action.fullscreen.tip";
+ actionIcon:"fullscreen";
+ mnemonic:P;
+ visible:{!isUndecorated()};
+ _help:{"ui.main.menu.file.fullscreen"};
+}
+
+#menuFileNormalscreen {
+ text:"jaxxdemo.action.normalscreen";
+ toolTipText:"jaxxdemo.action.normalscreen.tip";
+ actionIcon:"leave-fullscreen";
+ mnemonic:N;
+ visible:{isUndecorated()};
+ _help:{"ui.main.menu.file.leave-fullscreen"};
+}
+
+#menuFileExit{
+ text:"jaxxdemo.action.exit";
+ toolTipText:"jaxxdemo.action.exit.tip";
+ actionIcon:"exit";
+ mnemonic:X;
+ _help:{"ui.main.menu.file.exit"};
+}
+
+#menuHelp{
+ text:"jaxxdemo.menu.help";
+ mnemonic:e;
+ _help:{"ui.main.menu.help"};
+}
+
+#menuHelpHelp{
+ text:"jaxxdemo.action.help";
+ toolTipText:"jaxxdemo.action.help.tip";
+ actionIcon:"help";
+ mnemonic:e;
+ _help:{"ui.main.menu.help.help"};
+}
+
+#menuHelpSite{
+ text:"jaxxdemo.action.site";
+ toolTipText:"jaxxdemo.action.site.tip";
+ actionIcon:"site";
+ mnemonic:s;
+ _help:{"ui.main.menu.help.site"};
+}
+
+#menuHelpAbout{
+ text:"jaxxdemo.action.about";
+ toolTipText:"jaxxdemo.action.about.tip";
+ actionIcon:"about";
+ mnemonic:A;
+ _help:{"ui.main.menu.help.about"};
+}
+
+#showHelp{
+ toolTipText:"jaxxdemo.action.showHelp.tip";
+ actionIcon:"show-help";
+ borderPainted:false;
+ visible:true;
+}
+
+#navigation{
+ rootVisible:false;
+ largeModel:true;
+ font-size:11;
+}
+/*
+#splitpane{
+ orientation:{JSplitPane.HORIZONTAL_SPLIT};
+ _help:{"ui.main.body.db"};
+ resizeWeight:1.0;
+}*/
+
+#contentLayout{
+ useOnlyVisibleComponentDimension:true;
+}
+
+#content{
+ layout:{contentLayout};
+ _help:{"ui.main.body.db.view.content"};
+}
+/*
+#toolbar {
+ layout:{new BoxLayout(toolbar, 0)};
+ _help:{"ui.main.toolbar"};
+}*/
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,82 @@
+
+<JFrame id='mainFrame'
+ title="JAXX Demo"
+ width='1024'
+ height='800'
+ decorator='help'
+ undecorated='{getConfig().isFullScreen()}'
+ onWindowClosing='getHandler().close(mainFrame)'>
+
+ <style source='DemoUI.css'/>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'/>
+
+ <script><![CDATA[
+import jaxx.runtime.swing.navigation.*;
+import java.util.Locale;
+
+public DemoConfig getConfig() {
+ return getContextValue(DemoConfig.class);
+}
+
+protected DemoUIHandler getHandler() {
+ return getContextValue(DemoUIHandler.class);
+}
+
+protected DemoTreeHelper getTreeHelper() {
+ return getContextValue(DemoTreeHelper.class);
+}
+
+public boolean acceptLocale(Locale l, String expected) {
+ return l !=null && l.toString().equals(expected);
+}
+
+]]>
+ </script>
+
+ <JMenuBar id='menu'>
+
+ <JMenu id='menuFile'>
+ <JMenuItem id='menuFileConfiguration'
+ onActionPerformed="getHandler().showConfig(this)"/>
+ <JMenu id='menuFileLanguage'>
+ <JMenuItem id='menuFileLanguageFR'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.FRANCE)"/>
+ <JMenuItem id='menuFileLanguageUK'
+ onActionPerformed="getHandler().changeLanguage(this, Locale.UK)"/>
+ </JMenu>
+ <JSeparator/>
+ <JMenuItem id='menuFileFullscreen'
+ onActionPerformed="getHandler().changeScreen(this, true)"/>
+ <JMenuItem id='menuFileNormalscreen'
+ onActionPerformed="getHandler().changeScreen(this, false)"/>
+ <JSeparator/>
+ <JMenuItem id='menuFileExit'
+ onActionPerformed="getHandler().close(this)"/>
+ </JMenu>
+
+ <JMenu id='menuHelp'>
+ <JMenuItem id='menuHelpHelp'
+ onActionPerformed="getHandler().showHelp(this, null)"/>
+ <JMenuItem id='menuHelpSite'
+ onActionPerformed="getHandler().gotoSite(this)"/>
+ <JMenuItem id='menuHelpAbout'
+ onActionPerformed="getHandler().showAbout(this)"/>
+ </JMenu>
+
+ </JMenuBar>
+
+ <JSplitPane id='splitPane'>
+ <JScrollPane border='{null}'>
+ <JTree id='navigation'
+ model='{getTreeHelper().createTreeModel(this)}'
+ selectionModel="{getTreeHelper().createTreeHandler(this)}"
+ cellRenderer='{new NavigationTreeCellRenderer(this, 200)}'>
+ </JTree>
+ <!--model='{DemoTreeHelper.TREE_MODEL.getContextValue(this)}'-->
+ </JScrollPane>
+
+ <JPanel id='content'/>
+
+ </JSplitPane>
+</JFrame>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,292 @@
+/**
+ * *##% observe-swing
+ * Copyright (C) 2008 - 2009 IRD
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
+ */
+package jaxx.demo;
+
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+import java.awt.Desktop;
+import java.net.URL;
+import java.util.Locale;
+import javax.swing.SwingUtilities;
+import jaxx.runtime.DefaultApplicationContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.swing.AboutPanel;
+import jaxx.runtime.swing.editor.config.ConfigUI;
+import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
+import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+import org.nuiton.i18n.I18n;
+
+/**
+ * Le handler de l'ui principale.
+ *
+ * @author chemit
+ * @see DemoUI
+ */
+public class DemoUIHandler { //implements JAXXHelp {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(DemoUIHandler.class);
+ static final JAXXContextEntryDef<DemoUI> MAIN_UI_ENTRY_DEF = JAXXContextEntryDef.newDef("mainui", DemoUI.class);
+
+ /**
+ * Methode pour initialiser l'ui principale sans l'afficher.
+ *
+ * @param rootContext le context applicatif
+ * @param fullscreen flag pour indiquer si on doit ouvrir l'ui en model console (pleine ecran).
+ * @return l'ui instancie et initialisee mais non visible encore
+ */
+ public DemoUI initUI(DefaultApplicationContext rootContext, boolean fullscreen) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("fullscreen ? " + fullscreen);
+ }
+
+ // create restrict context for ui
+ JAXXInitialContext context = new JAXXInitialContext();
+
+ // share handler
+ context.add(this);
+
+ // share tree helper
+ context.add(rootContext.getContextValue(DemoTreeHelper.class));
+
+ // share config
+ context.add(rootContext.getContextValue(DemoConfig.class));
+
+ // instanciate ui
+ DemoUI ui = new DemoUI(context);
+
+ // keep it in root context
+ MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
+
+ // synch to error dialog
+ ErrorDialogUI.init(ui);
+
+ // set fullscreen propery on main ui
+ ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
+
+ return ui;
+ }
+
+ public void displayUI(final DemoUI ui, final NavigationTreeNode node) {
+
+ // expend all nodes of the demo tree
+ jaxx.runtime.SwingUtil.expandTree(ui.getNavigation());
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ // use best dimensions
+ ui.getSplitPane().resetToPreferredSizes();
+
+ String path;
+ if (node == null) {
+ // take first node
+ path = "$root/jaxxdemo.tree.component.swing";
+ } else {
+ // take selected node
+ path = node.getContextPath();
+ }
+ // select node
+ ui.getTreeHelper().selectNode(ui, ui.getNavigation(), path);
+
+ // show ui
+ ui.setVisible(true);
+ }
+ });
+ }
+
+ /**
+ * Permet de recharger l'ui principale et de changer de le mode d'affichage.
+ *
+ * @param rootContext le contexte applicatif
+ * @param fullscreen le type de fenetre à reouvrir
+ */
+ public void reloadUI(DefaultApplicationContext rootContext, boolean fullscreen) {
+
+ // scan main ui
+ DemoUI ui = getUI(rootContext);
+
+ NavigationTreeNode node = null;
+
+ if (ui != null) {
+
+ ui.getConfig().removeJaxxPropertyChangeListener();
+
+ node = ui.getTreeHelper().getSelectedNode(ui);
+
+ if (node != null) {
+ log.info("selected node " + node.getContextPath());
+ }
+
+ ErrorDialogUI.init(null);
+
+ ui.dispose();
+
+ ui.setVisible(false);
+
+ MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
+
+ }
+
+ ui = initUI(rootContext, fullscreen);
+
+ displayUI(ui, node);
+ }
+
+ /**
+ * Méthode pour changer de mode d'affichage.
+ * <p/>
+ * Si <code>fullscreen</code> est à <code>true</code> alors on passe en
+ * mode console (c'est à dire en mode plein écran exclusif), sinon on
+ * passe en mode fenetré normal.
+ *
+ * @param context l'ui principale de l'application
+ * @param fullscreen le nouvel état requis.
+ */
+ public void changeScreen(JAXXContext context, final boolean fullscreen) {
+
+ DemoUI ui = getUI(context);
+
+ // sauvegarde de l'état dans la configuration
+ ui.getConfig().setFullscreen(fullscreen);
+
+ // rechargement de l'ui
+ reloadUI(RunDemo.get(), fullscreen);
+ }
+
+ public void changeLanguage(JAXXContext context, Locale newLocale) {
+
+ DemoUI ui = getUI(context);
+
+ DemoConfig config = ui.getConfig();
+
+ // sauvegarde de la nouvelle locale
+ config.setLocale(newLocale);
+
+ // chargement de la nouvelle locale dans le système i18n
+ I18n.init(newLocale);
+
+ // rechargement de l'ui
+ reloadUI(RunDemo.get(), config.isFullScreen());
+ }
+
+ /**
+ * Ferme l'application.
+ *
+ * @param context l'ui principale de l'application
+ */
+ public void close(JAXXContext context) {
+ log.info("JAXX Demo quitting...");
+ try {
+
+ DemoUI ui = getUI(context);
+ ui.dispose();
+ } finally {
+ System.exit(0);
+ }
+ }
+
+ public void showConfig(JAXXContext context) {
+ DemoUI ui = getUI(context);
+ DemoConfig config = ui.getConfig();
+ ConfigUIModel model = new ConfigUIModel(config);
+
+ // categorie repertoires
+ model.addCategory(
+ n_("jaxxdemo.config.category.directories"),
+ n_("jaxxdemo.config.category.directories.description"),
+ DemoConfig.Option.CONFIG_FILE);
+
+ // others
+ model.addCategory(
+ n_("jaxxdemo.config.category.other"),
+ n_("jaxxdemo.config.category.other.description"),
+ DemoConfig.Option.FULL_SCREEN,
+ DemoConfig.Option.LOCALE);
+
+ ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "jaxxdemo.config.category.directories");
+
+ ConfigUIBuilder.showConfigUI(configUI, ui, false);
+ }
+
+// @Override
+ public void showHelp(JAXXContext context, String helpId) {
+// DemoUI mainUI = getUI(context);
+// ObserveHelpBroker helpBroker = context.getContextValue(ObserveHelpBroker.class);
+//
+// if (helpId == null) {
+// helpId = helpBroker.getDefaultID();
+// }
+// log.debug("show help " + helpId);
+// mainUI.getHelp().setCurrentID(helpId);
+ }
+
+ public void gotoSite(JAXXContext context) {
+
+ DemoUI ui = getUI(context);
+ DemoConfig config = ui.getConfig();
+
+ URL siteURL = config.getOptionAsURL("application.site.url");
+
+ log.info(_("jaxxdemo.message.goto.site", siteURL));
+
+ if (log.isDebugEnabled()) {
+ log.debug("goto " + siteURL);
+ }
+ if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ try {
+ Desktop.getDesktop().browse(siteURL.toURI());
+ } catch (Exception ex) {
+ log.error(ex.getMessage(), ex);
+ ErrorDialogUI.showError(ex);
+ }
+ }
+ }
+
+ public void showAbout(DemoUI ui) {
+
+ AboutPanel about = new AboutPanel();
+
+ about.setTitle(_("jaxxdemo.title.about"));
+ about.setIconPath("/icons/jaxx.png");
+ about.setAboutText(_("jaxxdemo.about.message"));
+ about.setBottomText(ui.getConfig().getCopyrightText());
+ about.setLicenseFile("META-INF/jaxx-example-LICENSE.txt");
+ about.setThirdpartyFile("META-INF/jaxx-example-THIRD-PARTY.txt");
+ about.init();
+ about.showInDialog(ui, true);
+ }
+
+ DemoUI getUI(JAXXContext context) {
+ if (context instanceof DemoUI) {
+ return (DemoUI) context;
+ }
+ DemoUI ui = MAIN_UI_ENTRY_DEF.getContextValue(context);
+ return ui;
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,171 @@
+package jaxx.demo;
+
+import jaxx.runtime.DefaultApplicationContext;
+import jaxx.runtime.swing.ErrorDialogUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.i18n.I18n;
+import static org.nuiton.i18n.I18n._;
+import org.nuiton.util.StringUtil;
+
+import jaxx.runtime.SwingUtil;
+
+/**
+ *
+ * @author chemit
+ */
+public class RunDemo {
+
+ /**
+ * Logger
+ */
+ private static Log log = LogFactory.getLog(RunDemo.class);
+ /**
+ * When application was started
+ */
+ private static long startingTime = System.nanoTime();
+ /**
+ * The singleton instance of the main context
+ */
+ protected static DefaultApplicationContext context;
+
+ public static void main(String[] args) {
+
+ startingTime = System.nanoTime();
+ log.info("Observe start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
+
+ try {
+
+ // init root context
+ // to enable javassist on webstart, must remove any securityManager,
+ // see if this can be dangerous (should not be since jnlp is signed ?)
+ // moreover it speeds up the loading :)
+ System.setSecurityManager(null);
+
+ long t0 = System.nanoTime();
+
+ I18n.setUniqueBundleName("jaxx-demo-i18n");
+
+ Runtime.getRuntime().addShutdownHook(new ShutdownHook());
+
+ // init root context
+ DefaultApplicationContext rootContext = init();
+
+ // share a tree helper
+ rootContext.setContextValue(new DemoTreeHelper());
+
+ // init config
+ DemoConfig config = new DemoConfig();
+ config.parse(args);
+
+ // share the config
+ rootContext.setContextValue(config);
+
+ long t00 = System.nanoTime();
+
+ // init i18n
+ I18n.init(config.getLocale());
+
+ log.info("language : " + config.getLocale());
+
+ if (log.isDebugEnabled()) {
+ log.debug("i18n loading time : " + (StringUtil.convertTime(t00, System.nanoTime())));
+ }
+
+ log.info(_("jaxxdemo.message.config.loaded", config.getVersion()));
+
+ // prepare ui look&feel and load ui properties
+
+ try {
+ SwingUtil.initNimbusLoookAndFeel();
+ } catch (Exception e) {
+ // could not find nimbus look-and-feel
+ log.warn(_("jaxxdemo.warning.nimbus.landf"));
+ } catch (Throwable e) {
+ log.warn(_("jaxxdemo.warning.no.ui"));
+
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("init done in " + (StringUtil.convertTime(t0, System.nanoTime())));
+ }
+
+ log.info(_("jaxxdemo.init.context.done", StringUtil.convertTime(startingTime, System.nanoTime())));
+
+ // on affiche l'ui principale
+ DemoUIHandler handler = new DemoUIHandler();
+
+ DemoUI ui = handler.initUI(rootContext, config.isFullScreen());
+
+ log.info(_("jaxxdemo.init.ui.done"));
+
+ handler.displayUI(ui, null);
+
+ } catch (Exception e) {
+ ErrorDialogUI.showError(e);
+ log.error(e.getMessage(), e);
+ System.exit(1);
+ }
+ }
+
+ /**
+ * @return <code>true</code> si le context a été initialisé via la méthode
+ * {@link #init()}, <ocde>false</code> autrement.
+ */
+ protected static boolean isInit() {
+ return context != null;
+ }
+
+ /**
+ * Permet l'initialisation du contexte applicatif et positionne
+ * l'context partagée.
+ * <p/>
+ * Note : Cette méthode ne peut être appelée qu'une seule fois.
+ * @return l'context partagée
+ * @throws IllegalStateException si un contexte applicatif a déja été positionné.
+ */
+ protected static synchronized DefaultApplicationContext init() throws IllegalStateException {
+ if (isInit()) {
+ throw new IllegalStateException("there is an already application context registred.");
+ }
+ context = new DefaultApplicationContext();
+ return context;
+ }
+
+ /**
+ * Récupération du contexte applicatif.
+ *
+ * @return l'context partagé du contexte.
+ * @throws IllegalStateException si le contexte n'a pas été initialisé via
+ * la méthode {@link #init()}
+ */
+ protected static DefaultApplicationContext get() throws IllegalStateException {
+ if (!isInit()) {
+ throw new IllegalStateException("no application context registred.");
+ }
+ return context;
+ }
+
+ protected static class ShutdownHook extends Thread {
+
+ public ShutdownHook() {
+ super("shutdown JAXXDemo");
+ }
+
+ @Override
+ public void run() {
+ try {
+ super.run();
+
+ //JAXXContext.get().close();
+ // force to kill main thread
+
+ log.info(_("jaxxdemo.init.closed", new java.util.Date()));
+ Runtime.getRuntime().halt(0);
+ } catch (Exception ex) {
+ log.error("error while closing " + ex.getMessage(), ex);
+ Runtime.getRuntime().halt(1);
+ }
+ }
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/BoxedDecoratorDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,91 @@
+
+<jaxx.demo.DemoPanel>
+ <jaxx.runtime.swing.BlockingLayerUI id='layerUI'
+ blockIcon='{SwingUtil.createImageIcon("action-block.png")}'
+ acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}'
+ useIcon='true'
+ blockingColor='{new Color(50,50,50)}'
+ acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L;
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ accept(e, "from icon of layer");
+ }
+ }}' />
+ <jaxx.runtime.swing.BlockingLayerUI2 id='layerUI2'
+ blockIcon='{SwingUtil.createImageIcon("action-block.png")}'
+ acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}'
+ acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L;
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ accept(e, "from icon of layer");
+ }
+ }}' />
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+void $afterCompleteSetup() {
+ for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
+ if (boxed == d) {
+ SwingUtil.getLayer(boxed).setUI(layerUI2);
+ continue;
+ }
+
+ jaxx.runtime.swing.BlockingLayerUI ui = layerUI.clone();
+ if ( boxed == c) {
+ ui.setBlock(true);
+ }
+ SwingUtil.getLayer(boxed).setUI(ui);
+ }
+}
+
+public void setLayer(boolean active) {
+ for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
+ if (boxed == d) {
+ continue;
+ }
+ jaxx.runtime.swing.BlockingLayerUI ui = (jaxx.runtime.swing.BlockingLayerUI)SwingUtil.getLayer(boxed).getUI();
+ if ( boxed == c) {
+ ui.setBlock(active);
+ }
+ ui.setUseIcon(active);
+ }
+}
+
+protected void accept(ActionEvent e, String suffix) {
+ JButton source = (JButton) e.getSource();
+ String clickedMessage = (String) source.getClientProperty("clickedText");
+ String msg = "'" + source.getText() + "' clicked - " + suffix + " : " + clickedMessage;
+ ((DefaultListModel)messages.getModel()).addElement(msg);
+}]]>
+ </script>
+ <Table id='demoPanel' fill='both' weightx='1'>
+ <row>
+ <cell>
+ <JCheckBox id='toggle' selected='true'
+ text='{toggle.isSelected() ? "Active layer" : "No layer"}'
+ onActionPerformed='setLayer(toggle.isSelected());'/>
+ </cell>
+ </row>
+ <row>
+ <cell weighty='0.5'>
+ <JPanel layout='{new GridLayout(1,3,3,3)}'>
+ <JButton text='button A' decorator='boxed' _clickedText='"button A was clicked"'
+ onActionPerformed='accept(event, "from button (no layer)")'/>
+ <JButton text='button B' decorator='boxed' _clickedText='"button B was clicked"'
+ onActionPerformed='accept(event, "from button (no layer)")'/>
+ <JButton id='c' text='button C (full block)' decorator='boxed' _clickedText='"button C was clicked"'
+ onActionPerformed='accept(event, "from button (no layer)");'/>
+ <JButton id='d' text='button D (full block 2)' decorator='boxed' _clickedText='"button D was clicked"'
+ onActionPerformed='accept(event, "from button (no layer)");'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weighty='0.5'>
+ <JScrollPane>
+ <JList id='messages' model='{new DefaultListModel()}'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/StatusMessagePanelDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,11 @@
+<jaxx.demo.DemoPanel>
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+ <JPanel layout='{new GridLayout(0,1)}' constraints='BorderLayout.CENTER'>
+ <JButton text='Fool me once'
+ onActionPerformed='p.setStatus(((JButton)event.getSource()).getText() + " ? shame on you!")'/>
+ <JButton text='Fool me twice'
+ onActionPerformed='p.setStatus(((JButton)event.getSource()).getText() + " ? shame on ...")'/>
+ </JPanel>
+ <jaxx.runtime.swing.StatusMessagePanel id='p' constraints='BorderLayout.SOUTH'/>
+ </JPanel>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/ComboEditorDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,35 @@
+
+<jaxx.demo.DemoPanel>
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Locale editor:' labelFor='{localeEditor}'/>
+ </cell>
+
+ <cell>
+ <LocaleEditor id='localeEditor'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='EnumEditor (language) :' labelFor='{languageEditor}'/>
+ </cell>
+ <cell>
+ <EnumEditor id='languageEditor' constructorParams='org.nuiton.i18n.LanguageEnum.class'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='EnumEditor (country) :' labelFor='{countryEditor}'/>
+ </cell>
+ <cell>
+ <EnumEditor id='countryEditor' constructorParams='org.nuiton.i18n.CountryEnum.class'/>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2">
+ <JTextArea text='{"locale : "+ localeEditor.getSelectedItem() + "\nlanguage : "+ languageEditor.getSelectedItem() + "\ncountry : " + countryEditor.getSelectedItem()}'/>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,46 @@
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+//localeEditor.loadI18nBundles();
+]]>
+ </script>
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Empty I18n editor:' labelFor='{localeEmptyEditor}'/>
+ </cell>
+ <cell>
+ <jaxx.runtime.swing.editor.I18nEditor id='localeEmptyEditor' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='I18n editor:' labelFor='{localeEditor}'/>
+ </cell>
+ <cell>
+ <jaxx.runtime.swing.editor.I18nEditor id='localeEditor'
+ locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='I18n editor with no text :' labelFor='{localeWithNoTextEditor}'/>
+ </cell>
+ <cell>
+ <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoTextEditor'
+ locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
+ showText='false'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='I18n editor with no icon :' labelFor='{localeWithNoIconEditor}'/>
+ </cell>
+ <cell>
+ <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoIconEditor'
+ locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
+ showIcon='false'/>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,132 @@
+
+<jaxx.demo.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}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifIntegerEditor2'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ 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}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor2'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ 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}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor2'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor2'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,78 @@
+package jaxx.demo.component.jaxx.editor;
+
+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);
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/BaseContent.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,81 @@
+
+<JPanel layout='{new BorderLayout()}'>
+
+ <Object id='data' javaBean='helper.getSelectedBean(this)'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+import jaxx.demo.component.jaxx.navigation.full.model.*;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+String getType(Object data) {
+ if (data == null) {
+ return "no type";
+ }
+ if (data instanceof java.util.List<?>) {
+ java.util.List<?> l = (java.util.List<?>) data;
+ if (l.isEmpty()) {
+ return "Empty collection";
+ }
+ return "Collection of " + l.size() + " " + l.get(0).getClass().getSimpleName() + "(s)";
+ }
+ return data.getClass().getSimpleName();
+}
+
+String getContent(Object data) {
+ if (data == null) {
+ return "no content";
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (data instanceof java.util.List) {
+ for (Object o : ((java.util.List)data)) {
+ buffer.append(o).append("\n");
+ }
+ } else {
+ buffer.append(data);
+ }
+ return buffer.toString();
+}
+
+ImageIcon getImage(Object data) {
+ if (data == null) {
+ return null;
+ }
+ if (data instanceof Movie) {
+ return SwingUtil.createIcon(((Movie)data).getImage());
+ }
+ if (data instanceof People) {
+ return SwingUtil.createIcon(((People)data).getImage());
+ }
+ return null;
+}
+ ]]>
+ </script>
+
+ <JSplitPane id='splitPane'
+ orientation='{JSplitPane.VERTICAL_SPLIT}'
+ resizeWeight='0.5'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'>
+ <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}'
+ editable='false'
+ font-size='11'
+ text='{getContent(getData())}'/>
+ </JScrollPane>
+
+ <JScrollPane border='{new TitledBorder("Picture")}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
+ minimumSize='{SwingUtil.newMinDimension()}'>
+
+ <JLabel icon='{getImage(getData())}'/>
+
+ </JScrollPane>
+
+ </JSplitPane>
+</JPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,54 @@
+
+<jaxx.demo.DemoPanel>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'
+ useOnlyVisibleComponentDimension='true'/>
+
+ <script><![CDATA[
+import jaxx.runtime.swing.navigation.NavigationTreeCellRenderer;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+setContextValue(helper.createMovies(this), " movies");
+
+void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ navigation.setSelectionInterval(0, 0);
+ splitPane.resetToPreferredSizes();
+ }
+ });
+ jaxx.runtime.SwingUtil.expandTree(navigation);
+}
+ ]]>
+ </script>
+
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_NEVER}'>
+
+ <JTree id="navigation"
+ font-size='11'
+ rootVisible='false'
+ model='{helper.createTreeModel(this)}'
+ selectionModel="{helper.createTreeHandler(this)}"
+ cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />
+ <!--model='{helper.createTreeModel(this, helper.createMovies())}'-->
+
+ </JScrollPane>
+
+ <JPanel id="content" layout="{contentLayout}" />
+
+ </JSplitPane>
+
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,209 @@
+package jaxx.demo.component.jaxx.navigation.full;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import jaxx.demo.component.jaxx.navigation.full.model.Movie;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+
+import static jaxx.runtime.JAXXContextEntryDef.newListDef;
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+import java.util.Set;
+import jaxx.demo.component.jaxx.navigation.full.model.People;
+import jaxx.runtime.Decorator;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.MultiJXPathDecorator;
+
+
+import javax.swing.JPanel;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
+import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ */
+public class FullNavigationTreeHelper extends NavigationTreeHelper {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+
+ public FullNavigationTreeHelper() {
+ super("full");
+ }
+
+ public java.util.List<Movie> createMovies(JAXXContext context) {
+ java.util.List<Movie> result = new java.util.ArrayList<Movie>();
+ People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
+ People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
+ People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
+
+ Movie m = new Movie("0", "Nacho libre", 1996, "/jaxx/demo/images/nacho.jpg");
+ m.addActor(a);
+ m.addActor(a2);
+ m.addActor(a3);
+ result.add(m);
+
+ m = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m.addActor(a);
+ m.addActor(a2);
+ result.add(m);
+
+ context.setContextValue(result, "movies");
+
+ return result;
+ }
+
+ @Override
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
+
+ List<Movie> movies = context.getContextValue(List.class, "movies");
+
+ log.info("for " + movies.size() + " movie(s)");
+
+ NavigationTreeNode rootNode, moviesNode, movieNode, actorsNode;
+
+ log.info("start creating demo model");
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/");
+
+ Decorator<Movie> movieDecorator = MultiJXPathDecorator.newDecorator(Movie.class, "${title}$s##${year}$s", "##", " - ");
+ Decorator<People> peopleDecorator = MultiJXPathDecorator.newDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " ");
+
+ Set<People> actors = new HashSet<People>();
+ // construction du noeud root
+ // il ne contient pas de context et ne sera pas visible
+ rootNode = builder.buildEmptyRoot(null, "$root");
+
+ // construction du noeud avec les films recupere la liste des films
+ // dans le context avec la clef movies
+ // navigation path = $root/movies
+ moviesNode = builder.build(
+ rootNode,
+ _("movies"),
+ newListDef("movies"),
+ "movies",
+ null,
+ null);
+
+ for (Movie m : movies) {
+
+ // navigation path = $root/movies/m.id
+ movieNode = builder.build(
+ moviesNode,
+ movieDecorator,
+ "..[@id=\"" + m.getId() + "\"]",
+ m.getId(),
+ null,
+ null);
+
+ // navigation path = $root/movies/m.id/actors
+ actorsNode = builder.build(
+ movieNode,
+ _("actors"),
+ "../actors",
+ "actors",
+ null,
+ null);
+
+ for (People p : m.getActors()) {
+ // navigation path = $root/movies/m.id/actors/p.id
+
+ builder.build(
+ actorsNode,
+ peopleDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ actors.add(p);
+ }
+ }
+
+ // construction du noeud avec les acteurs
+ actorsNode = builder.build(rootNode, _("actors"),
+ newListDef("actors"),
+ "actors", null, null);
+
+ for (People p : actors) {
+ // navigation path = $root/actors/p.id
+
+ builder.build(
+ actorsNode,
+ peopleDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ NavigationTreeModel model = builder.getModel();
+
+ context.setContextValue(movies, "movies");
+ context.setContextValue(new ArrayList<People>(actors), "actors");
+
+ if (log.isDebugEnabled()) {
+ builder.printModel(context, model.getRoot());
+ }
+
+ // save tree model in context
+ setTreeModel(context, model);
+
+ return model;
+ }
+
+ public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+
+
+ log.info("create handler");
+
+ NavigationTreeHandler handler = new NavigationTreeHandlerWithCardLayout(
+ getPrefix(),
+ BaseContent.class,
+ null,
+ context,
+ Strategy.PER_NODE) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected NavigationTreeModel getNavigationTreeModel() {
+ return getSafeTreeModel(getContext());
+ }
+
+ @Override
+ protected JPanel getContentContainer() {
+ return getContext().getContent();
+ }
+
+ @Override
+ protected CardLayout2 getContentLayout() {
+ return getContext().getContentLayout();
+ }
+
+ @Override
+ protected void treateError(Exception e) {
+ ErrorDialogUI.showError(e);
+ }
+
+ FullNavigationTreeDemo getContext() {
+ return (FullNavigationTreeDemo) this.context;
+ }
+ };
+ // on ne peut selectionner qu'un seul noeud a la fois
+ handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+
+ // save handler in ui context
+ setTreeHandler(context, handler);
+ return handler;
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/FullNavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,107 @@
+package jaxx.demo.component.jaxx.navigation.full.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,97 @@
+package jaxx.demo.component.jaxx.navigation.full.model;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/full/model/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,60 @@
+package jaxx.demo.component.jaxx.navigation.item;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.runtime.swing.JAXXTree.JAXXTreeModel;
+import jaxx.runtime.swing.navigation.ItemNavigationCardPanel;
+import jaxx.runtime.swing.navigation.ItemTreeNavigationAdapter;
+
+/**
+ *
+ * @author letellier
+ */
+public class ExempleItemTreeNavigationAdapter extends ItemTreeNavigationAdapter{
+
+ Item currentItem = null;
+
+ public ExempleItemTreeNavigationAdapter(JAXXObject context, JAXXTree tree, ItemNavigationCardPanel cardPanel){
+ super(context, tree, cardPanel);
+
+ ItemTreeNavigationDemo demo = (ItemTreeNavigationDemo)context;
+ demo.addPropertyChangeListener("date", new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (currentItem != null && !(currentItem.getValue() instanceof Class)){
+ currentItem.setValue((Date)evt.getNewValue());
+ }
+ }
+ });
+
+ demo.addPropertyChangeListener("string", new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (currentItem != null && !(currentItem.getValue() instanceof Class)){
+ currentItem.setValue((String)evt.getNewValue());
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void valueChanged(Object data) {
+ ItemTreeNavigationDemo demo = (ItemTreeNavigationDemo)context;
+ currentItem = ((JAXXTreeModel)tree.getModel()).findItem(data);
+ if (data instanceof String){
+ demo.setString((String)data);
+ } else if (data instanceof Date){
+ demo.setDate((Date)data);
+ } else {
+ demo.setString("");
+ demo.setDate(null);
+ }
+ }
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ExempleItemTreeNavigationAdapter.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,41 @@
+<jaxx.demo.DemoPanel>
+
+ <String id='string' javaBean='null'/>
+ <Date id='date' javaBean='null'/>
+
+ <script>
+import jaxx.runtime.swing.navigation.*;
+import org.jdesktop.swingx.JXDatePicker;
+
+void $afterCompleteSetup() {
+ new ExempleItemTreeNavigationAdapter(this, nav, content);
+}
+ </script>
+
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+ <JSplitPane constraints='BorderLayout.CENTER'>
+ <JScrollPane>
+ <JTree id='nav' rootVisible='{false}'>
+ <!-- Allow to diplay associated pane without value -->
+ <item id='stringItemParent' label='String' value='{String.class}'>
+ <item id='string1Item' label='String1' value='{new String("Ceci est un String")}' selected='true'/>
+ <item id='string2Item' label='String2' value='{new String("Celui-ci un autre")}'/>
+ </item>
+ <item id='dateItemParent' label='Date' value='{Date.class}'>
+ <item id='dateItem' label='CurrentDate' value='{new Date()}'/>
+ </item>
+ </JTree>
+ </JScrollPane>
+ <!-- Card panel, only ItemNavigationPanel children is alowed -->
+ <ItemNavigationCardPanel id="content">
+ <!-- The associated type is passed by the constructor -->
+ <ItemNavigationPanel id='stringPanel' constructorParams='String.class' layout='{new FlowLayout()}'>
+ <JTextField id='stringTextField' text='{getString()}' onKeyReleased='setString(stringTextField.getText())'/>
+ </ItemNavigationPanel>
+ <ItemNavigationPanel id='datePanel' constructorParams='Date.class' layout='{new FlowLayout()}'>
+ <JXDatePicker id='datePicker' date='{getDate()}' onActionPerformed='setDate(datePicker.getDate())'/>
+ </ItemNavigationPanel>
+ </ItemNavigationCardPanel>
+ </JSplitPane>
+ </JPanel>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JButtonDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,29 @@
+<jaxx.demo.DemoPanel>
+ <style>
+ JButton.fancy {
+ foreground: blue;
+ font-face: Arial;
+ font-size: 18;
+ }
+
+ JButton.fancy:mouseover {
+ foreground: red;
+ font-style: italic;
+ }
+ </style>
+
+ <script>
+ public void buttonClicked(JButton button) {
+ JOptionPane.showMessageDialog(this, button.getText() + " clicked!", "onActionPerformed",
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+ </script>
+
+ <javax.swing.ImageIcon id='pencil' constructorParams='getClass().getResource("/jaxx/demo/images/pencil_black.gif")'/>
+
+ <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <JButton text='Simple Button' onActionPerformed='buttonClicked((JButton) event.getSource())'/>
+ <JButton text='Fancy Button' styleClass='fancy' icon='{pencil}'
+ onActionPerformed='buttonClicked((JButton) event.getSource())'/>
+ </VBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,38 @@
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+ public String getText(boolean bold, boolean italic, boolean underline) {
+ String text ="Sample Text";
+ if (bold)
+ text = "<b>" + text + "</b>";
+ if (italic)
+ text = "<i>" + text + "</i>";
+ if (underline)
+ text = "<u>" + text + "</u>";
+ return "<html>" + text;
+ }
+ ]]></script>
+
+ <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <Table anchor='west'>
+ <row>
+ <cell>
+ <JCheckBox id='bold' text='Bold' mnemonic='B'/>
+ </cell>
+ <cell rows='3'>
+ <JLabel font='{new Font("Arial", 0, 18)}'
+ text='{getText(bold.isSelected(), italic.isSelected(), underline.isSelected())}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JCheckBox id='italic' text='Italic' mnemonic='I'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JCheckBox id='underline' text='Underline' mnemonic='U'/>
+ </cell>
+ </row>
+ </Table>
+ </VBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JCheckBoxMenuItemDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,59 @@
+<JMenuItemDemo>
+ <style>
+ .form {
+ enabled: { enabledCheckBox.isSelected() };
+ editable: { editableCheckBox.isSelected() };
+ }
+ </style>
+
+ <JMenuBar id='menuBar'>
+ <JMenu text='View'>
+ <JCheckBoxMenuItem id='enabledCheckBox' text='Enabled' selected='true'/>
+ <JCheckBoxMenuItem id='editableCheckBox' text='Editable' selected='true'/>
+ </JMenu>
+ </JMenuBar>
+
+ <Table id='framePanel' anchor='northwest'>
+ <row>
+ <cell>
+ <JLabel text='First Name:' displayedMnemonic='F' labelFor='{firstName}'/>
+ </cell>
+
+ <cell weightx='1' fill='horizontal'>
+ <JTextField id='firstName' styleClass="form"/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Last Name:' displayedMnemonic='L' labelFor='{lastName}'/>
+ </cell>
+
+ <cell fill='horizontal'>
+ <JTextField id='lastName' styleClass="form"/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Email Address:' displayedMnemonic='E' labelFor='{email}'/>
+ </cell>
+
+ <cell fill='horizontal'>
+ <JTextField id='email' styleClass="form"/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Comments:' displayedMnemonic='C' labelFor='{comments}'/>
+ </cell>
+
+ <cell weightx='1' weighty='1' fill='both'>
+ <JScrollPane width='150' height='75'>
+ <JTextArea id='comments' styleClass="form"/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+</JMenuItemDemo>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JComboBoxDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,22 @@
+
+<jaxx.demo.DemoPanel>
+ <Table id='demoPanel'>
+ <row>
+ <cell>
+ <JLabel text='Button label:'/>
+ </cell>
+
+ <cell>
+ <JComboBox id='comboBox' editable='true'>
+ <item value='OK' selected='true'/>
+ <item value='Cancel'/>
+ <item value='Help'/>
+ </JComboBox>
+ </cell>
+
+ <cell>
+ <JButton text='{comboBox.getSelectedItem()}'/>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JDialogDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,79 @@
+<jaxx.demo.DemoPanel>
+ <script>
+ String username;
+ String password;
+
+ private class OKAction extends javax.swing.AbstractAction {
+ public OKAction() {
+ putValue(NAME, "OK");
+ }
+
+
+ public void actionPerformed(ActionEvent e) {
+ username = usernameField.getText();
+ password = new String(passwordField.getPassword());
+ dialog.dispose();
+ }
+ }
+
+
+ private class CancelAction extends javax.swing.AbstractAction {
+ public CancelAction() {
+ putValue(NAME, "Cancel");
+ }
+
+
+ public void actionPerformed(ActionEvent e) {
+ dialog.dispose();
+ }
+ }
+ {
+ JRootPane rootPane = dialog.getRootPane();
+ rootPane.setDefaultButton(ok);
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "cancel");
+ rootPane.getActionMap().put("cancel", new CancelAction());
+ }
+ </script>
+
+ <JDialog title='Sign on' id='dialog' modal='true' onWindowOpened='dialog.setLocationRelativeTo(demoPanel);
+ passwordField.setText("");'>
+ <Table>
+ <row>
+ <cell>
+ <JLabel text='Username:' displayedMnemonic='U' labelFor='{usernameField}'/>
+ </cell>
+
+ <cell>
+ <JTextField id='usernameField'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Password:' displayedMnemonic='P' labelFor='{passwordField}'/>
+ </cell>
+
+ <cell>
+ <JPasswordField id='passwordField'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2'>
+ <JPanel layout='{new GridLayout(1, 0, 6, 6)}'>
+ <JButton id='ok' text='OK' action='{new OKAction()}'/>
+ <JButton text='Cancel' action='{new CancelAction()}'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </JDialog>
+
+ <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <JButton text='Show password dialog' onActionPerformed='dialog.setVisible(true)'/>
+ <VBox>
+ <JLabel text='{username != null ? "Username: " + username : ""}'/>
+ <JLabel text='{password != null ? "Password: " + password : ""}'/>
+ </VBox>
+ </VBox>
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,59 @@
+<jaxx.demo.DemoPanel>
+ <Table id='demoPanel'>
+ <row>
+ <cell>
+ <JLabel text='Supported Swing components:'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JScrollPane>
+ <JList>
+ <item value='JApplet'/>
+ <item value='JButton'/>
+ <item value='JCheckBox'/>
+ <item value='JCheckBoxMenuItem'/>
+ <item value='JColorChooser'/>
+ <item value='JComboBox'/>
+ <item value='JDesktopPane'/>
+ <item value='JDialog'/>
+ <item value='JEditorPane'/>
+ <item value='JFileChooser'/>
+ <item value='JFormattedTextField'/>
+ <item value='JFrame'/>
+ <item value='JInternalFrame'/>
+ <item value='JLabel'/>
+ <item value='JLayeredPane'/>
+ <item value='JList'/>
+ <item value='JMenu'/>
+ <item value='JMenuBar'/>
+ <item value='JMenuItem'/>
+ <item value='JOptionPane'/>
+ <item value='JPanel'/>
+ <item value='JPasswordField'/>
+ <item value='JPopupMenu'/>
+ <item value='JProgressBar'/>
+ <item value='JRadioButton'/>
+ <item value='JRadioButtonMenuItem'/>
+ <item value='JScrollBar'/>
+ <item value='JScrollPane'/>
+ <item value='JSeparator'/>
+ <item value='JSlider'/>
+ <item value='JSpinner'/>
+ <item value='JSplitPane'/>
+ <item value='JTabbedPane'/>
+ <item value='JTable'/>
+ <item value='JTextArea'/>
+ <item value='JTextField'/>
+ <item value='JTextPane'/>
+ <item value='JToggleButton'/>
+ <item value='JToolBar'/>
+ <item value='JTree'/>
+ <item value='JWindow'/>
+ </JList>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JMenuItemDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,23 @@
+<jaxx.demo.DemoPanel>
+ <script>
+ private void displayMessage() {
+ JOptionPane.showMessageDialog(demoPanel, "Menu item clicked");
+ }
+ </script>
+
+ <JPanel id='demoPanel'>
+ <JDesktopPane width='350' height='400' background='{null}'>
+ <JInternalFrame title='JMenu demo' width='300' height='250' resizable='true'>
+ <JMenuBar id='menuBar'>
+ <JMenu text='Demo'>
+ <JMenuItem text='Message Box' onActionPerformed='displayMessage()'/>
+ </JMenu>
+ </JMenuBar>
+
+ <JPanel id='framePanel'>
+ <JLabel text='JMenu demo' id='demoMessage' horizontalAlignment='center'/>
+ </JPanel>
+ </JInternalFrame>
+ </JDesktopPane>
+ </JPanel>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JPasswordFieldDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,10 @@
+<jaxx.demo.DemoPanel>
+ <VBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <HBox>
+ <JLabel text='Password:' displayedMnemonic='P' labelFor='{password}'/>
+ <JPasswordField id='password'/>
+ </HBox>
+
+ <JLabel text='You entered: {new String(password.getPassword())}'/>
+ </VBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JProgressBarDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,77 @@
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+ import javax.swing.Timer;
+
+ int red = 0;
+ int green = 0;
+ int blue = 0;
+ int speed = 2;
+ int redDirection = 1;
+ int greenDirection = 1;
+ int blueDirection = 1;
+
+ Timer redTimer = new Timer(5, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ red = Math.max(0, Math.min(255, red + speed * redDirection));
+ if (red == 0 || red == 255)
+ redDirection = -redDirection;
+ }
+ });
+
+ Timer greenTimer = new Timer(50, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ green = Math.max(0, Math.min(255, green + speed * greenDirection));
+ if (green == 0 || green == 255)
+ greenDirection = -greenDirection;
+ }
+ });
+
+ Timer blueTimer = new Timer(500, new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ blue = Math.max(0, Math.min(255, blue + speed * blueDirection));
+ if (blue == 0 || blue == 255)
+ blueDirection = -blueDirection;
+ }
+ });
+
+ redTimer.start();
+ greenTimer.start();
+ blueTimer.start();
+ ]]></script>
+
+ <Table insets='6' id='demoPanel'>
+ <row>
+ <cell columns='3'>
+ <JLabel text='Welcome to the JAXX framework!' font='{UIManager.getFont("Label.font").deriveFont(18f)}'
+ foreground='{new Color(red, green, blue)}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='3' fill='horizontal'>
+ <JProgressBar foreground='{new Color(red, 0, 0)}' value='{red}' maximum='255'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='3' fill='horizontal'>
+ <JProgressBar foreground='{new Color(0, green, 0)}' value='{green}' maximum='255'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='3' fill='horizontal'>
+ <JProgressBar foreground='{new Color(0, 0, blue)}' value='{blue}' maximum='255'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell weightx='1' anchor='east'>
+ <JButton text='Start' onActionPerformed='redTimer.start(); greenTimer.start(); blueTimer.start()'/>
+ </cell>
+ <cell>
+ <JButton text='Stop' onActionPerformed='redTimer.stop(); greenTimer.stop(); blueTimer.stop()'/>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,11 @@
+<jaxx.demo.DemoPanel>
+ <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <VBox>
+ <JRadioButton text='Animal' value='Lynx.jpg' buttonGroup='radioButtons' selected='true'/>
+ <JRadioButton text='Vegetable' buttonGroup='radioButtons' value='Tomato.jpg'/>
+ <JRadioButton text='Mineral' buttonGroup='radioButtons' value='Amethyst.jpg'/>
+ </VBox>
+
+ <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/" + radioButtons.getSelectedValue()))}'/>
+ </HBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JRadioButtonMenuItemDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,14 @@
+<JMenuItemDemo>
+ <JMenuBar id='menuBar'>
+ <JMenu text='Font size'>
+ <JRadioButtonMenuItem text='10' value='{new Integer(10)}' buttonGroup='fontSize'/>
+ <JRadioButtonMenuItem text='12' value='{new Integer(12)}' buttonGroup='fontSize' selected='true'/>
+ <JRadioButtonMenuItem text='14' value='{new Integer(14)}' buttonGroup='fontSize'/>
+ <JRadioButtonMenuItem text='18' value='{new Integer(18)}' buttonGroup='fontSize'/>
+ <JRadioButtonMenuItem text='24' value='{new Integer(24)}' buttonGroup='fontSize'/>
+ </JMenu>
+ </JMenuBar>
+
+ <JLabel id='demoMessage' text='Font size: {fontSize.getSelectedValue()}' horizontalAlignment='center'
+ font='{UIManager.getFont("Label.font").deriveFont(fontSize.getSelectedValue() != null ? (float) ((Integer) fontSize.getSelectedValue()).intValue() : 12)}'/>
+</JMenuItemDemo>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSliderDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,12 @@
+<jaxx.demo.DemoPanel>
+ <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <VBox>
+ <JSlider id='red' maximum='255' value='200'/>
+ <JSlider id='green' maximum='255' value='180'/>
+ <JSlider id='blue' maximum='255' value='240'/>
+ </VBox>
+
+ <JPanel border='{BorderFactory.createEtchedBorder()}' width='64' height='64'
+ background='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/>
+ </HBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSpinnerDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,13 @@
+<jaxx.demo.DemoPanel>
+ <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <JLabel text='Spacing:' displayedMnemonic='S' labelFor='{spinner}'/>
+
+ <JSpinner minimum='0' maximum='50' id='spinner'/>
+
+ <VBox spacing='{((Integer) spinner.getValue()).intValue()}'>
+ <JLabel text='Use the spinner to'/>
+ <JLabel text='adjust the spacing'/>
+ <JLabel text='between these lines'/>
+ </VBox>
+ </HBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JSplitPaneDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,13 @@
+<jaxx.demo.DemoPanel>
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+ <JSplitPane>
+ <JScrollPane>
+ <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/Amethyst.jpg"))}'/>
+ </JScrollPane>
+
+ <JScrollPane>
+ <JLabel icon='{new ImageIcon(getClass().getResource("/jaxx/demo/images/Lynx.jpg"))}'/>
+ </JScrollPane>
+ </JSplitPane>
+ </JPanel>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextAreaDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,33 @@
+<jaxx.demo.DemoPanel>
+ <Table id='demoPanel' anchor='northwest'>
+ <row>
+ <cell>
+ <JLabel text='Normal text:' displayedMnemonic='N' labelFor='{textArea}'/>
+ </cell>
+
+ <cell weightx='1' fill='both'>
+ <JScrollPane height='120'>
+ <JTextArea id='textArea' text='Try typing some text here.'/>
+ </JScrollPane>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Upper case text:'/>
+ </cell>
+
+ <cell weightx='1' fill='both'>
+ <JScrollPane height='120'>
+ <JTextArea editable='false' background='{null}' text='{textArea.getText().toUpperCase()}'/>
+ </JScrollPane>
+ </cell>
+ </row>
+
+ <row>
+ <cell weighty='1'>
+ <JPanel/>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JTextFieldDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,22 @@
+<jaxx.demo.DemoPanel>
+ <JPanel id='demoPanel'>
+ <Table>
+ <row>
+ <cell>
+ <JLabel text='Your name:' displayedMnemonic='n' labelFor='{textField}'/>
+ </cell>
+
+ <cell>
+ <JTextField id='textField'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2'>
+ <JButton text='Greet'
+ onActionPerformed='JOptionPane.showMessageDialog(demoPanel, "Hello, " + textField.getText() + "!")'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,9 @@
+<jaxx.demo.DemoPanel>
+ <HBox id='demoPanel' horizontalAlignment='center' verticalAlignment='middle'>
+ <JToggleButton text='1' id='one'/>
+ <JToggleButton text='2' id='two'/>
+ <JToggleButton text='3' id='three'/>
+
+ <JLabel text='Total: {(one.isSelected() ? 1 : 0) + (two.isSelected() ? 2 : 0) + (three.isSelected() ? 3 : 0)}'/>
+ </HBox>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BaseBeanDataBinding.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,21 @@
+<jaxx.demo.DemoPanel>
+
+ <!-- a full java bean property of the class -->
+ <Boolean id='editing' javaBean='false'/>
+
+ <!-- not full java bean property (must add script...) -->
+ <Boolean id='editing2' constructorParams='false'/>
+
+ <String id='contentMessage' javaBean='"message..."'/>
+
+ <script>
+ public Boolean isEditing2() { return editing2; }
+
+ public void setEditing2(Boolean newValue) {
+ Boolean oldValue = this.editing2;
+ this.editing2 = newValue;
+ firePropertyChange("editing2", oldValue, newValue) ;
+ }
+ </script>
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BeanDataBindingDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,47 @@
+<BaseBeanDataBinding>
+
+ <Boolean id='editing3' javaBean='true'/>
+
+ <Table id='demoPanel'>
+ <row>
+ <cell columns='2'>
+ <JLabel text='{getContentMessage()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JPanel>
+ <JButton visible='{!isEditing()}' text='edit' onActionPerformed='setEditing(true);'/>
+ <JButton visible='{isEditing()}' text='close' onActionPerformed='setEditing(false);'/>
+ </JPanel>
+ </cell>
+ <cell weightx='1' fill='both'>
+ <JTextField enabled='{isEditing()}' text='to edit'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JPanel>
+ <JButton visible='{!isEditing2()}' text='edit2' onActionPerformed='setEditing2(true);'/>
+ <JButton visible='{isEditing2()}' text='close2' onActionPerformed='setEditing2(false);'/>
+ </JPanel>
+ </cell>
+ <cell weightx='1' fill='both'>
+ <JTextField enabled='{isEditing2()}' text="to edit 2"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JPanel>
+ <JButton visible='{!isEditing3()}' text='edit3' onActionPerformed='setEditing3(true);'/>
+ <JButton visible='{isEditing3()}' text='close3' onActionPerformed='setEditing3(false);'/>
+ </JPanel>
+ </cell>
+ <cell weightx='1' fill='both'>
+ <JTextField id='edit3' enabled='{isEditing3()}' text="{getContentMessage()}"
+ onKeyReleased='setContentMessage(edit3.getText())'/>
+ </cell>
+ </row>
+ </Table>
+
+</BaseBeanDataBinding>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,103 @@
+package jaxx.demo.feature.validation;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+
+public class Identity {
+
+ protected String firstName = "";
+
+ protected String lastName = "";
+
+ protected String email = "dummy(a)codelutin.com";
+
+ protected int age = 51;
+
+ protected File config = new File("/tmp");
+
+ protected File dir = new File("/tmp");
+
+ PropertyChangeSupport p;
+
+ public Identity() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ 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);
+ }
+
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public File getConfig() {
+ return config;
+ }
+
+ public File getDir() {
+ return dir;
+ }
+
+ public void setFirstName(String firstName) {
+ String oldFirstName = this.firstName;
+ this.firstName = firstName;
+ p.firePropertyChange("firstName", oldFirstName, firstName);
+ }
+
+ public void setLastName(String lastName) {
+ String oldLastName = this.lastName;
+ this.lastName = lastName;
+ p.firePropertyChange("lastName", oldLastName, lastName);
+ }
+
+ public void setEmail(String email) {
+ String oldEmail = this.email;
+ this.email = email;
+ p.firePropertyChange("email", oldEmail, email);
+ }
+
+ public void setAge(int age) {
+ int oldAge = this.age;
+ this.age = age;
+ p.firePropertyChange("age", oldAge, age);
+ }
+
+ public void setConfig(File config) {
+ File oldConfig = this.config;
+ this.config = config;
+ p.firePropertyChange("config", oldConfig, config);
+ }
+
+ public void setDir(File dir) {
+ File oldDir = this.dir;
+ this.dir = dir;
+ p.firePropertyChange("dir", oldDir, dir);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Identity.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,66 @@
+package jaxx.demo.feature.validation;
+
+import java.beans.*;
+
+public class Model {
+
+ protected String text = "text";
+
+ protected String text2 = "text2";
+
+ protected int ratio = 51;
+
+
+ PropertyChangeSupport p;
+
+ public Model() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ 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);
+ }
+
+
+ public String getText() {
+ return text;
+ }
+
+ public String getText2() {
+ return text2;
+ }
+
+ public int getRatio() {
+ return ratio;
+ }
+
+ public void setText(String text) {
+ String oldText = this.text;
+ this.text = text;
+ p.firePropertyChange("text", oldText, text);
+ }
+
+ public void setText2(String text2) {
+ String oldText2 = this.text2;
+ this.text2 = text2;
+ p.firePropertyChange("text2", oldText2, text2);
+ }
+
+ public void setRatio(int ratio) {
+ int oldRatio = this.ratio;
+ this.ratio = ratio;
+ p.firePropertyChange("ratio", oldRatio, ratio);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Model.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Validation.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Validation.css (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/Validation.css 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,5 @@
+JSlider {
+ paintTicks: true;
+ minorTickSpacing: 5;
+ majorTickSpacing: 10;
+}
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,325 @@
+<jaxx.demo.DemoPanel>
+ <style source="Validation.css"/>
+
+<script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+void $afterCompleteSetup() {
+}]]>
+</script>
+ <!-- models -->
+ <Model id='model1'/>
+ <Model id='model2'/>
+ <Identity id='identity'/>
+
+ <!-- errors model -->
+ <!-- Not existing :) -->
+ <!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
+ onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
+ <field name="text" component="_text"/>
+ <field name="text2" component="_text2"/>
+ <field name="ratio" component="_ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator3' autoField='true' bean='identity'
+ uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
+ <field name="email" component="email2"/>
+ </BeanValidator>
+
+ <Table fill='both' id='demoPanel'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model1.getText()}'
+ _validatorLabel='{n_("form.text")}'
+ onKeyReleased='model1.setText(text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model1.getText2()}'
+ _validatorLabel='{n_("form.text2")}'
+ onKeyReleased='model1.setText2(text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model1.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
+ onKeyReleased='model2.setText(_text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
+ onKeyReleased='model2.setText2(_text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
+ onStateChanged='model2.setRatio(_ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model2.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
+ layout='{new GridLayout()}' width='250' height='180'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='firstName' text='{identity.getFirstName()}'
+ onKeyReleased='identity.setFirstName(firstName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='lastName' text='{identity.getLastName()}'
+ onKeyReleased='identity.setLastName(lastName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='email2' text='{identity.getEmail()}'
+ onKeyReleased='identity.setEmail(email2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
+ onStateChanged='identity.setAge(age.getValue())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file :'/>
+ </cell>
+ <cell>
+ <JTextField id='config' text='{identity.getConfig()}'
+ onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Working directory:'/>
+ </cell>
+ <cell>
+ <JTextField id='dir' text='{identity.getDir()}'
+ onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getFirstName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getLastName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getEmail()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getAge()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getConfig()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Directory file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getDir()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane>
+ <JList id='errorList' model='{errors}'
+ cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,331 @@
+<jaxx.demo.DemoPanel>
+ <style source="Validation.css"/>
+
+ <!-- models -->
+ <Model id='model1'/>
+ <Model id='model2'/>
+ <Identity id='identity'/>
+
+ <!-- errors model -->
+ <!-- Not existing :) -->
+ <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
+ <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
+ onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
+
+ <!-- validators -->
+ <BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
+ <field name="text"/>
+ <field name="text2"/>
+ <field name="ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator2' bean='model2' uiClass="jaxx.runtime.validator.swing.ui.IconValidationUI">
+ <field name="text" component="_text"/>
+ <field name="text2" component="_text2"/>
+ <field name="ratio" component="_ratio"/>
+ </BeanValidator>
+ <BeanValidator id='validator3' autoField='true' bean='identity'
+ uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
+ <field name="email" component="email2"/>
+ </BeanValidator>
+
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.SwingUtil;
+
+void $afterCompleteSetup() {
+ jaxx.runtime.SwingValidatorUtil.installUI(errorTable, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
+}
+]]></script>
+
+ <Table fill='both' id='demoPanel'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='{model1.getText()}'
+ onKeyReleased='model1.setText(text.getText())'
+ _validatorLabel='{n_("form.text")}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text2' text='{model1.getText2()}'
+ onKeyReleased='model1.setText2(text2.getText())'
+ _validatorLabel='{n_("form.text2")}'
+ />
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
+ onStateChanged='model1.setRatio(ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model1.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model1.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Form2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
+ onKeyReleased='model2.setText(_text.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
+ onKeyReleased='model2.setText2(_text2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
+ onStateChanged='model2.setRatio(_ratio.getValue())'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Model2")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Text2:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{model2.getText2()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Ratio:'/>
+ </cell>
+ <cell>
+ <JLabel text='{model2.getRatio()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identify Form")}'
+ layout='{new GridLayout()}' width='250' height='180'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='firstName' text='{identity.getFirstName()}'
+ onKeyReleased='identity.setFirstName(firstName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='lastName' text='{identity.getLastName()}'
+ onKeyReleased='identity.setLastName(lastName.getText())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='email2' text='{identity.getEmail()}'
+ onKeyReleased='identity.setEmail(email2.getText())'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JSlider id='age' minimum='0' maximum='100' value='{identity.getAge()}'
+ onStateChanged='identity.setAge(age.getValue())'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file :'/>
+ </cell>
+ <cell>
+ <JTextField id='config' text='{identity.getConfig()}'
+ onKeyReleased='identity.setConfig(new java.io.File(config.getText()))'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Working directory:'/>
+ </cell>
+ <cell>
+ <JTextField id='dir' text='{identity.getDir()}'
+ onKeyReleased='identity.setDir(new java.io.File(dir.getText()))'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <JPanel border='{BorderFactory.createTitledBorder("Identity Model")}'
+ layout='{new GridLayout()}' width='250' height='120'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='FirstName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getFirstName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='LastName:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getLastName()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Email:'/>
+ </cell>
+ <cell weightx='1'>
+ <JLabel text='{identity.getEmail()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Age:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getAge()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Config file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getConfig()}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='Directory file:'/>
+ </cell>
+ <cell>
+ <JLabel text='{identity.getDir()}'/>
+ </cell>
+ </row>
+ </Table>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
+ width='500'>
+ <JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
+ <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true' autoCreateRowSorter='true'
+ autoResizeMode='2' cellSelectionEnabled='false' selectionMode='0'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns='2' fill="both">
+ <JPanel layout='{new GridLayout(1,2,0,0)}'>
+ <JButton id='cancel' text='cancel'
+ onActionPerformed='JOptionPane.showMessageDialog(this, cancel.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ <JButton id='ok' text='valid'
+ onActionPerformed='JOptionPane.showMessageDialog(this, ok.getText() + " clicked!", "onActionPerformed", JOptionPane.INFORMATION_MESSAGE);'/>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,68 @@
+#table {
+ border: { BorderFactory . createEmptyBorder( 4, 4, 4, 4 )
+}
+
+;
+font-face:
+
+"Trebuchet MS"
+;
+}
+
+#display {
+ background: #BCE5AD;
+ opaque: true;
+ horizontalAlignment: right;
+ border: { BorderFactory . createBevelBorder( BevelBorder . LOWERED )
+}
+
+;
+font-size:
+
+22
+;
+font-weight: bold
+
+;
+}
+
+#display:{
+ object . getText( ) . startsWith( "-" )
+}
+
+{
+foreground: red
+
+;
+}
+
+JButton {
+ font-size: 18;
+ width: 80;
+ height: 35;
+}
+
+JButton.digit {
+ foreground: blue;
+}
+
+JButton#dot {
+ font-size: 20;
+}
+
+JButton.operator {
+ font-size: 16;
+ foreground: #009900;
+}
+
+JButton.clear {
+ foreground: red;
+}
+
+JButton:mouseover {
+ font-weight: bold;
+}
+
+JButton.operator:mouseover {
+ font-weight: normal;
+}
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,89 @@
+<jaxx.demo.DemoPanel>
+ <style source='Calculator.css'/>
+ <script><![CDATA[
+ plus.setText("+");
+ sign.setText("+/-");
+]]></script>
+ <!-- use fully-qualified name just in case this is compiled into a different package -->
+ <CalculatorEngine id='engine'/>
+
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell columns='4'>
+ <JLabel id='display' text='{engine.getDisplayText()}'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2'>
+ <JButton id='c' text='C' onActionPerformed='engine.clear()' styleClass='clear'/>
+ </cell>
+ <cell>
+ <JButton id='ce' text='CE' onActionPerformed='engine.clearEntry()' styleClass='clear'/>
+ </cell>
+ <cell>
+ <JButton id='equals' text='=' onActionPerformed='engine.equal()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d7' text='7' onActionPerformed='engine.digit(7)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d8' text='8' onActionPerformed='engine.digit(8)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d9' text='9' onActionPerformed='engine.digit(9)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='plus' onActionPerformed='engine.add()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d4' text='4' onActionPerformed='engine.digit(4)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d5' text='5' onActionPerformed='engine.digit(5)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d6' text='6' onActionPerformed='engine.digit(6)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='subtract' text='-' onActionPerformed='engine.subtract()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d1' text='1' onActionPerformed='engine.digit(1)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d2' text='2' onActionPerformed='engine.digit(2)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='d3' text='3' onActionPerformed='engine.digit(3)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='multiply' text='x' onActionPerformed='engine.multiply()' styleClass='operator'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JButton id='d0' text='0' onActionPerformed='engine.digit(0)' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='sign' onActionPerformed='engine.toggleSign()' styleClass='operator'/>
+ </cell>
+ <cell>
+ <JButton id='dot' text='.' onActionPerformed='engine.dot()' styleClass='digit'/>
+ </cell>
+ <cell>
+ <JButton id='divide' text='÷' onActionPerformed='engine.divide()' styleClass='operator'/>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,177 @@
+package jaxx.demo.fun;
+
+import java.beans.*;
+import java.math.*;
+
+public class CalculatorEngine {
+ public static final String DISPLAY_TEXT_PROPERTY = "displayText";
+
+ public static final int ADD = 0;
+ public static final int SUBTRACT = 1;
+ public static final int MULTIPLY = 2;
+ public static final int DIVIDE = 3;
+ public static final int RESULT = 4;
+
+ private int operation = -1;
+ private boolean clear = true; // true to clear on next key
+ private String displayText = "0";
+ private BigDecimal value;
+ private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+
+
+ public String getDisplayText() {
+ return displayText;
+ }
+
+
+ public void setDisplayText(String displayText) {
+ String oldDisplayText = this.displayText;
+ this.displayText = displayText;
+ firePropertyChange(DISPLAY_TEXT_PROPERTY, oldDisplayText, displayText);
+ }
+
+
+ public void clear() {
+ clearEntry();
+ value = new BigDecimal(0);
+ operation = -1;
+ }
+
+
+ public void clearEntry() {
+ setDisplayText("0");
+ clear = true;
+ }
+
+
+ private void checkClear() {
+ if (clear) {
+ setDisplayText("");
+ clear = false;
+ }
+ }
+
+
+ public void digit(int digit) {
+ checkClear();
+ setDisplayText(getDisplayText() + String.valueOf(digit));
+ }
+
+
+ public void dot() {
+ checkClear();
+ if (getDisplayText().indexOf('.') == -1) {
+ if (getDisplayText().length() == 0) {
+ setDisplayText("0.");
+ } else {
+ setDisplayText(getDisplayText() + '.');
+ }
+ }
+ }
+
+
+ public void toggleSign() {
+ String text = getDisplayText();
+ if (text.startsWith("-")) {
+ text = text.substring(1);
+ } else if (!text.equals("0")) {
+ text = '-' + text;
+ }
+ setDisplayText(text);
+ }
+
+
+ public void equal() {
+ BigDecimal displayValue = new BigDecimal(getDisplayText());
+ BigDecimal newValue = displayValue;
+ switch (operation) {
+ case ADD:
+ newValue = value.add(displayValue);
+ break;
+ case SUBTRACT:
+ newValue = value.subtract(displayValue);
+ break;
+ case MULTIPLY:
+ newValue = value.multiply(displayValue);
+ break;
+ case DIVIDE:
+ newValue = value.divide(displayValue, 8, BigDecimal.ROUND_HALF_UP);
+ break;
+ }
+ value = newValue;
+ setDisplayText(toString(newValue));
+ clear = true;
+ operation = -1;
+ }
+
+
+ public static String toString(BigDecimal decimal) {
+ // can't use stripTrailingZeros, as it wasn't introduced until 1.5
+ String result = decimal.toString();
+ if (result.indexOf(".") != -1) {
+ while (result.endsWith("0")) {
+ result = result.substring(0, result.length() - 1);
+ }
+ if (result.endsWith(".")) {
+ result = result.substring(0, result.length() - 1);
+ }
+ }
+ return result;
+ }
+
+
+ public void operation(int operation) {
+ if (this.operation != -1) {
+ equal();
+ } else {
+ value = new BigDecimal(getDisplayText());
+ clear = true;
+ }
+ this.operation = operation;
+ }
+
+
+ public void add() {
+ operation(ADD);
+ }
+
+
+ public void subtract() {
+ operation(SUBTRACT);
+ }
+
+
+ public void multiply() {
+ operation(MULTIPLY);
+ }
+
+
+ public void divide() {
+ operation(DIVIDE);
+ }
+
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(listener);
+ }
+
+
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ propertyChangeSupport.addPropertyChangeListener(property, listener);
+ }
+
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(listener);
+ }
+
+
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ propertyChangeSupport.removePropertyChangeListener(property, listener);
+ }
+
+
+ protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+ propertyChangeSupport.firePropertyChange(property, oldValue, newValue);
+ }
+}
\ No newline at end of file
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CalculatorEngine.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/CounterDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,12 @@
+<jaxx.demo.DemoPanel>
+ <script>int count;</script>
+ <JPanel id='demoPanel'>
+ <JTextField text='{count}' constraints='BorderLayout.NORTH'/>
+ <HBox constraints='BorderLayout.SOUTH'>
+ <JButton text='Dec (-)' onActionPerformed='count--'/>
+ <JButton text='Reset' onActionPerformed='count = 0'/>
+ <JButton text='Inc (+)' onActionPerformed='count++'/>
+ </HBox>
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyle.css 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,43 @@
+JSlider {
+ paintTicks: true;
+}
+
+JSlider.color {
+ minorTickSpacing: 10;
+ majorTickSpacing: 50;
+ border: { BorderFactory . createEmptyBorder( 1, 1, 1, 1 )
+}
+
+;
+}
+
+JSlider.color:focused {
+ border: { BorderFactory . createLineBorder( Color . BLACK, 1 )
+}
+
+;
+}
+
+JSlider#red:focused {
+ background: #E7ADAD;
+}
+
+JSlider#green:focused {
+ background: #B2E7AD;
+}
+
+JSlider#blue:focused {
+ background: #ADB2E7;
+}
+
+JSlider#dummySize {
+ minorTickSpacing: 2;
+ majorTickSpacing: 6;
+}
+
+JRadioButton {
+ enabled: { backgroundCheckbox . isSelected( )
+}
+
+;
+}
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/LabelStyleDemo.jaxx 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,85 @@
+<jaxx.demo.DemoPanel>
+ <style source="LabelStyle.css"/>
+
+ <Table id='demoPanel' anchor='north' fill='both'>
+ <row>
+ <cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
+ <Table anchor='west' fill='both'>
+ <row>
+ <cell>
+ <JLabel text='Text:'/>
+ </cell>
+ <cell weightx='1'>
+ <JTextField id='text' text='Data Binding'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Red:'/>
+ </cell>
+ <cell>
+ <JSlider id='red' value='128' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Green:'/>
+ </cell>
+ <cell>
+ <JSlider id='green' value='0' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Blue:'/>
+ </cell>
+ <cell>
+ <JSlider id='blue' value='255' maximum='255' styleClass='color'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JLabel text='Size:'/>
+ </cell>
+ <cell>
+ <JSlider id='dummySize' value='36' minimum='6' maximum='60'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns='2' fill='both' weighty='1'>
+ <JPanel border='{BorderFactory.createTitledBorder("Preview")}'
+ height='90'
+ layout='{new BorderLayout()}'>
+ <VBox background='{(Color)( backgroundCheckbox.isSelected() ? backgroundColor.getSelectedValue() : null)}'
+ margin='0'
+ horizontalAlignment='center'
+ verticalAlignment='middle'>
+ <JLabel text='{text.getText()}' font-size='{dummySize.getValue()}'
+ foreground='{new Color(red.getValue(), green.getValue(), blue.getValue())}'/>
+ </VBox>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+
+ <cell>
+ <VBox spacing='0' border='{BorderFactory.createTitledBorder("Background")}'>
+ <JCheckBox id='backgroundCheckbox' text='Show Background'/>
+ <JRadioButton text='Red' buttonGroup='backgroundColor' value='{Color.RED}' selected='true'/>
+ <JRadioButton text='Orange' buttonGroup='backgroundColor' value='{Color.ORANGE}'/>
+ <JRadioButton text='Yellow' buttonGroup='backgroundColor' value='{Color.YELLOW}'/>
+ <JRadioButton text='Green' buttonGroup='backgroundColor' value='{Color.GREEN}'/>
+ <JRadioButton text='Cyan' buttonGroup='backgroundColor' value='{Color.CYAN}'/>
+ <JRadioButton text='Blue' buttonGroup='backgroundColor' value='{Color.BLUE}'/>
+ <JRadioButton text='Purple' buttonGroup='backgroundColor' value='{new Color(160, 30, 255)}'/>
+ </VBox>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties (rev 0)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,173 @@
+-=
+.=
+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=
+Comments\:=
+Config\ file\ \:=
+Config\ file\:=
+Cyan=
+Dec\ (-)=
+Demo=
+Directory\ file\:=
+Editable=
+Email\ Address\:=
+Email\:=
+Empty\ I18n\ editor\:=
+Enabled=
+EnumEditor\ (country)\ \:=
+EnumEditor\ (language)\ \:=
+Fancy\ Button=
+First\ Name\:=
+FirstName\:=
+Font\ size=
+Fool\ me\ once=
+Fool\ me\ twice=
+Green=
+Green\:=
+Greet=
+I18n\ editor\ with\ no\ icon\ \:=
+I18n\ editor\ with\ no\ text\ \:=
+I18n\ editor\:=
+Inc\ (+)=
+Italic=
+JAXX\ Demo=
+JMenu\ demo=
+Last\ Name\:=
+LastName\:=
+Locale\ editor\:=
+Message\ Box=
+Mineral=
+Normal\ text\:=
+OK=
+Orange=
+Password\:=
+Purple=
+Ratio\:=
+Red=
+Red\:=
+Reset=
+Show\ Background=
+Show\ password\ dialog=
+Sign\ on=
+Simple\ Button=
+Size\:=
+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=
+actors=
+adjust\ the\ spacing=
+between\ these\ lines=
+button\ A=
+button\ B=
+button\ C\ (full\ block)=
+button\ D\ (full\ block\ 2)=
+cancel=
+close=Disable
+close2=Disable 2
+close3=Disable 3
+edit=Edit
+edit2=Edit 2
+edit3=Edit 3
+form.ratio=Ratio
+form.text=Text
+form.text2=Text 2
+form2.ratio=Form 2 Ratio
+form2.text=Form 2 Text
+form2.text2=Form 2 Text 2
+jaxxdemo.about.message=<h3>JAXX Demo</h3>Demo du framework JAXX <hr/><p>Ce projet a \u00E9t\u00E9 r\u00E9alis\u00E9 par la soci\u00E9t\u00E9 <a href\="http\://codelutin.com">Codelutin</a> en 2009.</p><br/><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-example">site du projet</a>.
+jaxxdemo.action.about=About...
+jaxxdemo.action.about.tip=About JAXXDemo...
+jaxxdemo.action.configuration=Preferences
+jaxxdemo.action.configuration.tip=Change the preferences of the application
+jaxxdemo.action.exit=Quit
+jaxxdemo.action.exit.tip=Quit JAXXDemo
+jaxxdemo.action.fullscreen=Full screen
+jaxxdemo.action.fullscreen.tip=Change to full screen mode
+jaxxdemo.action.help=Help
+jaxxdemo.action.help.tip=Display help
+jaxxdemo.action.locale.fr=French
+jaxxdemo.action.locale.fr.tip=Change to french language
+jaxxdemo.action.locale.uk=English
+jaxxdemo.action.locale.uk.tip=Change to english language
+jaxxdemo.action.normalscreen=Normal screen
+jaxxdemo.action.normalscreen.tip=Change to normal screen mode
+jaxxdemo.action.site=Web site
+jaxxdemo.action.site.tip=Go to the web site
+jaxxdemo.config.category.directories=Files
+jaxxdemo.config.category.directories.description=Files used by application
+jaxxdemo.config.category.other=Others
+jaxxdemo.config.category.other.description=Others preferences
+jaxxdemo.config.configFileName.description=Configuration file name
+jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
+jaxxdemo.config.ui.locale=Locale of the application
+jaxxdemo.init.closed=JAXXDemo was closed at %1$s
+jaxxdemo.init.context.done=Context initialized in %1$s
+jaxxdemo.init.ui.done=UI initialized.
+jaxxdemo.menu.file=File
+jaxxdemo.menu.file.locale=Languages
+jaxxdemo.menu.help=Help
+jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded.
+jaxxdemo.message.goto.site=Go to JAXXDemo Web site
+jaxxdemo.title.about=About JAXXDemo...
+jaxxdemo.tree.component.jaxx=JAXX Components
+jaxxdemo.tree.component.jaxx.editor=Editors
+jaxxdemo.tree.component.jaxx.tree.navigation=Navigation trees
+jaxxdemo.tree.component.swing=Swing Components
+jaxxdemo.tree.component.swing.buttons=Buttons
+jaxxdemo.tree.component.swing.form=Form elements
+jaxxdemo.tree.component.swing.form.text=Text
+jaxxdemo.tree.component.swing.layout=Layouts
+jaxxdemo.tree.component.swing.menu=Menus
+jaxxdemo.tree.component.swing.window=windows
+jaxxdemo.tree.feature=Features
+jaxxdemo.tree.features.databinding=Data Binding
+jaxxdemo.tree.features.validation=Validation
+jaxxdemo.tree.fun=Fun
+jaxxdemo.warning.nimbus.landf=Could not init nymbus look and feel, you need at leasr version 1.6u10 of java.
+jaxxdemo.warning.no.ui=No ui environnement detected
+movies=Movies
+numbereditor.normal.float=Signed float
+numbereditor.normal.int=Signed integer
+numbereditor.positive.float=Positive float
+numbereditor.positive.int=Positive integer
+numbereditor.type=Type
+numbereditor.with.auto.popup=With auto popup
+numbereditor.without.auto.popup=Without auto popup
+valid=
+x=
Added: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties (rev 0)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,173 @@
+-=-
+.=.
+0=0
+1=1
+10=10
+12=12
+14=14
+18=18
+2=2
+24=24
+3=3
+4=4
+5=5
+6=6
+7=7
+8=8
+9=9
+Age\:=Age \:
+Animal=Animal
+Blue=Bleu
+Blue\:=bleu \:
+Bold=En gras
+Button\ label\:=Libell\u00E9 du label
+C=C
+CE=CE
+Cancel=Annuler
+Comments\:=Commentaire
+Config\ file\ \:=Fichier de configuration
+Config\ file\:=Fichier de configuration \:
+Cyan=Bleu cyan
+Dec\ (-)=
+Demo=Demonstration
+Directory\ file\:=
+Editable=Editable
+Email\ Address\:=Courriel
+Email\:=Courriel
+Empty\ I18n\ editor\:=Editeur I18n vide
+Enabled=Activ\u00E9
+EnumEditor\ (country)\ \:=Editeur de pays
+EnumEditor\ (language)\ \:=Editeur de langue
+Fancy\ Button=Bouton 'Fancy'
+First\ Name\:=Pr\u00E9nom
+FirstName\:=Pr\u00E9nom \:
+Font\ size=Taille de la police
+Fool\ me\ once=
+Fool\ me\ twice=
+Green=Vert
+Green\:=Vert \:
+Greet=
+I18n\ editor\ with\ no\ icon\ \:=Editeur I18n sans icone \:
+I18n\ editor\ with\ no\ text\ \:=Editeur I18n sans texte \:
+I18n\ editor\:=Editeur I18n
+Inc\ (+)=Incr\u00E9menter (+)
+Italic=Italique
+JAXX\ Demo=
+JMenu\ demo=
+Last\ Name\:=Nom \:
+LastName\:=Nom
+Locale\ editor\:=Editeur de locale
+Message\ Box=
+Mineral=
+Normal\ text\:=
+OK=
+Orange=
+Password\:=Mot de passe
+Purple=Pourpre
+Ratio\:=
+Red=Rouge
+Red\:=rouge \:
+Reset=Reinitialiser
+Show\ Background=Voir le fond
+Show\ password\ dialog=Voir l'\u00E9diteur de mot de passe
+Sign\ on=Signer
+Simple\ Button=Bouton simple
+Size\:=Taille \:
+Spacing\:=Espacement \:
+Start=D\u00E9marrer
+Stop=Arr\u00EAter
+Supported\ Swing\ components\:=Composants Swing support\u00E9s
+Text2\:=Text 2
+Text\:=Texte \:
+Underline=soulign\u00E9
+Upper\ case\ text\:=Texte en majuscule
+Use\ the\ spinner\ to=Utiliser la jauge pour
+Username\:=Utilisateur \:
+Vegetable=L\u00E9gumes
+View=Vue
+Welcome\ to\ the\ JAXX\ framework\!=Bienvenu dans le framework JAXX
+Working\ directory\:=R\u00E9pertoire de travail
+Yellow=Jaune
+Your\ name\:=Votre nom \:
+\\u00f7=
+actors=Acteurs
+adjust\ the\ spacing=
+between\ these\ lines=
+button\ A=Bouton A
+button\ B=Bouton B
+button\ C\ (full\ block)=Bouton C (blocage compl\u00EAt)
+button\ D\ (full\ block\ 2)=Bouton D (blocage compl\u00EAt)
+cancel=Annuler
+close=Fermer
+close2=Fermer 2
+close3=Fermer 3
+edit=Editer
+edit2=Editer 2
+edit3=Editer 3
+form.ratio=Form \: ratio
+form.text=Form \: text
+form.text2=Form \: text2
+form2.ratio=Form2 \: ratio
+form2.text=Form2 \: text
+form2.text2=Form2 \: text2
+jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/kaxx/jaxx-demo">site du projet</a>.
+jaxxdemo.action.about=A propos
+jaxxdemo.action.about.tip=A propos de JAXX Demo...
+jaxxdemo.action.configuration=Configuration
+jaxxdemo.action.configuration.tip=Modifier la configuration
+jaxxdemo.action.exit=Quitter
+jaxxdemo.action.exit.tip=Quitter JAXX Demo
+jaxxdemo.action.fullscreen=Plein \u00E9cran
+jaxxdemo.action.fullscreen.tip=Passer en mode pleine \u00E9cran
+jaxxdemo.action.help=Aide
+jaxxdemo.action.help.tip=Affichier l'aide
+jaxxdemo.action.locale.fr=Fran\u00E7ais
+jaxxdemo.action.locale.fr.tip=Changer la langue en fran\u00E7ais
+jaxxdemo.action.locale.uk=Anglais
+jaxxdemo.action.locale.uk.tip=Changer la langue en anglais
+jaxxdemo.action.normalscreen=Ecran normal
+jaxxdemo.action.normalscreen.tip=Revenir en mode normal
+jaxxdemo.action.site=Site internet
+jaxxdemo.action.site.tip=Acc\u00E9der au site de l'application sur internet
+jaxxdemo.config.category.directories=R\u00E9pertoires
+jaxxdemo.config.category.directories.description=R\u00E9pertoires de l'application
+jaxxdemo.config.category.other=Autre
+jaxxdemo.config.category.other.description=Autres options
+jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
+jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
+jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES)
+jaxxdemo.init.closed=JAXX Demo a \u00E9t\u00E9 ferm\u00E9 \u00E0 %1$s
+jaxxdemo.init.context.done=Initialisation du contexte termin\u00E9e en %1$s.
+jaxxdemo.init.ui.done=Initialisation de l'interface graphique termin\u00E9e.
+jaxxdemo.menu.file=Fichier
+jaxxdemo.menu.file.locale=Langues
+jaxxdemo.menu.help=Aide
+jaxxdemo.message.config.loaded=Configuration de JAXX Demo v. %1$s charg\u00E9e.
+jaxxdemo.message.goto.site=Acc\u00E9der au site de JAXX Demo (%1$s)
+jaxxdemo.title.about=A propos de JAXX Demo...
+jaxxdemo.tree.component.jaxx=Composants JAXX
+jaxxdemo.tree.component.jaxx.editor=Editeurs
+jaxxdemo.tree.component.jaxx.tree.navigation=Arbre de navigation
+jaxxdemo.tree.component.swing=Composants Swing
+jaxxdemo.tree.component.swing.buttons=Boutons
+jaxxdemo.tree.component.swing.form=Elements de formulaire
+jaxxdemo.tree.component.swing.form.text=Texte
+jaxxdemo.tree.component.swing.layout=Layouts
+jaxxdemo.tree.component.swing.menu=Menus
+jaxxdemo.tree.component.swing.window=Fen\u00EAtres
+jaxxdemo.tree.feature=Fonctionnalit\u00E9s
+jaxxdemo.tree.features.databinding=Data binding
+jaxxdemo.tree.features.validation=Validation
+jaxxdemo.tree.fun=Contestes
+jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
+jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
+movies=Films
+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=valide
+x=x
Added: trunk/jaxx-demo/src/main/resources/icons/action-about.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-about.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-accept.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-accept.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-block.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-block.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-close.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-close.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-config.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-config.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-exit.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-exit.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-fullscreen.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-fullscreen.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-help.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-help.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-i18n-fr.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-i18n-fr.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-i18n-uk.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-i18n-uk.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-leave-fullscreen.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-leave-fullscreen.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-show-help.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-show-help.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-site.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-site.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/action-translate.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/action-translate.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/icons/jaxx.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/icons/jaxx.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-error-validation.xml
===================================================================
--- trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-error-validation.xml (rev 0)
+++ trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-error-validation.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,49 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <field name="firstName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a firstName.</message>
+ </field-validator>
+ </field>
+ <field name="lastName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a lastName.</message>
+ </field-validator>
+ </field>
+
+ <field name="email">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for email.</message>
+ </field-validator>
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail.</message>
+ </field-validator>
+ </field>
+
+ <field name="config">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for config.</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>The configuration file ${config} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="dir">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for dir.</message>
+ </field-validator>
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>The directory ${dir} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="age">
+ <field-validator type="int">
+ <param name="min">18</param>
+ <message>Your are too young (min ${min} )</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-info-validation.xml
===================================================================
--- trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-info-validation.xml (rev 0)
+++ trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-info-validation.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,49 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!--field name="firstName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a firstName.</message>
+ </field-validator>
+ </field>
+ <field name="lastName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a lastName.</message>
+ </field-validator>
+ </field>
+
+ <field name="email">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for email.</message>
+ </field-validator>
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail.</message>
+ </field-validator>
+ </field>
+
+ <field name="config">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for config.</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>The configuration file ${config} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="dir">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for dir.</message>
+ </field-validator>
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>The directory ${dir} does not exist.</message>
+ </field-validator>
+ </field-->
+
+ <field name="age">
+ <field-validator type="int">
+ <param name="min">25</param>
+ <message>You are still young ( old ${min} ) </message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-warning-validation.xml
===================================================================
--- trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-warning-validation.xml (rev 0)
+++ trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Identity-warning-validation.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,49 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!--field name="firstName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a firstName.</message>
+ </field-validator>
+ </field>
+ <field name="lastName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a lastName.</message>
+ </field-validator>
+ </field>
+
+ <field name="email">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for email.</message>
+ </field-validator>
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail.</message>
+ </field-validator>
+ </field>
+
+ <field name="config">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for config.</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>The configuration file ${config} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="dir">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for dir.</message>
+ </field-validator>
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>The directory ${dir} does not exist.</message>
+ </field-validator>
+ </field-->
+
+ <field name="age">
+ <field-validator type="int">
+ <param name="max">88</param>
+ <message>Info : Your are older than ${max} !</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-error-validation.xml
===================================================================
--- trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-error-validation.xml (rev 0)
+++ trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-error-validation.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,35 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!-- Field Validators for email field -->
+ <field name="text">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for text.</message>
+ </field-validator>
+ </field>
+
+ <field name="text2">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for text2.</message>
+ </field-validator>
+ </field>
+
+ <field name="ratio">
+ <field-validator type="int">
+ <param name="min">20</param>
+ <param name="max">50</param>
+ <message>Ratio needs to be between ${min} and ${max}</message>
+ </field-validator>
+ </field>
+
+ <!-- Plain Validator 1 -->
+ <validator type="expression">
+ <param name="expression">text.startsWith("poussin")</param>
+ <message>Email not starts with poussin</message>
+ </validator>
+ <validator type="expression">
+ <param name="expression">text2.startsWith("chemit")</param>
+ <message>Email not starts with chemit</message>
+ </validator>
+</validators>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-info-validation.xml
===================================================================
--- trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-info-validation.xml (rev 0)
+++ trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-info-validation.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,13 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!-- Field Validators for email field -->
+ <field name="text">
+ <field-validator type="fieldexpression">
+ <param name="expression"><![CDATA[ text != null && text.length() > 10]]></param>
+ <message>Text should have more than 10 caracters</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-warning-validation.xml
===================================================================
--- trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-warning-validation.xml (rev 0)
+++ trunk/jaxx-demo/src/main/resources/jaxx/demo/feature/validation/Model-warning-validation.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,18 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!-- Field Validators for email field -->
+ <field name="text">
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail for text.</message>
+ </field-validator>
+ </field>
+
+ <field name="text2">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for text2.</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Amethyst.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Amethyst.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Lynx.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Lynx.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Tomato.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/Tomato.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/ana.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/ana.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/hector.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/hector.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/jack.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/jack.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/joe.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/joe.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/nacho.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/nacho.jpg
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/nacho2.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/nacho2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/pencil_black.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/main/resources/jaxx/demo/images/pencil_black.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/log4j.properties (rev 0)
+++ trunk/jaxx-demo/src/main/resources/log4j.properties 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,10 @@
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+log4j.logger.jaxx.demo=INFO
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeHandler=DEBUG
+log4j.logger.org.nuiton=WARN
Added: trunk/jaxx-demo/src/site/rst/images/Components-screenshot.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/site/rst/images/Components-screenshot.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/site/rst/images/webstart.gif
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-demo/src/site/rst/images/webstart.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-demo/src/site/rst/index.rst
===================================================================
--- trunk/jaxx-demo/src/site/rst/index.rst (rev 0)
+++ trunk/jaxx-demo/src/site/rst/index.rst 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,43 @@
+===================
+Examples/Components
+===================
+
+The Components demo displays many different Swing components being used in a variety of ways; it is JAXX's equivalent
+of the SwingSet demo. Various pages use advanced features such as data binding, scripting, event handling, and
+CSS stylesheets.
+
+Examples/Calculator
+===================
+
+This is an implementation of Challenge #2 from the `XUL Grand Coding Challenge 2004`_ . Because this example program
+has been implemented in so many different languages, you can easily compare JAXX's
+syntax against the competition and decide for yourself which you prefer.
+
+Screen shot
+-----------
+
+.. image:: images/Components-screenshot.gif
+
+Set it in action
+----------------
+
+|webstart|
+
+To run this example in `Java Web Start`_, click the `following link`_.
+
+For more details about the `Jaxx Demo webstart`_.
+
+Source code
+-----------
+
+Unlike the other examples, the source code for Components is too big to display here. You can view it yourself by
+downloading JAXX, and you can also view the source code for the individual demos by clicking the "Source" tabs.
+
+
+.. _Java Web Start: http://java.sun.com/products/javawebstart/
+
+.. |webstart| image:: images/webstart.gif
+
+.. _following link: ./launch.jnlp
+
+.. _Jaxx Demo webstart: jnlp-report.html
Added: trunk/jaxx-demo/src/site/site.xml
===================================================================
--- trunk/jaxx-demo/src/site/site.xml (rev 0)
+++ trunk/jaxx-demo/src/site/site.xml 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <src>${site.home.url}/jaxx.png</src>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="${project.url}" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur" inherited="top">
+ <item name="Accueil" href="index.html"/>
+ <item name="Lancer la démo" href="jnlp/launch.jnlp"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ <menu ref="modules"/>
+
+ </body>
+</project>
Added: trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java
===================================================================
--- trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java (rev 0)
+++ trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java 2009-10-03 23:10:18 UTC (rev 1552)
@@ -0,0 +1,37 @@
+package jaxx.demo;
+
+import jaxx.demo.feature.validation.Model;
+import jaxx.demo.feature.validation.Identity;
+import java.io.File;
+import java.util.Iterator;
+import java.util.SortedSet;
+import jaxx.runtime.validator.AbstractBeanValidatorDetectorTest;
+import jaxx.runtime.validator.BeanValidator;
+import org.junit.BeforeClass;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author chemit
+ */
+public class BeanValidatorDetectorTest extends AbstractBeanValidatorDetectorTest {
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ AbstractBeanValidatorDetectorTest.setUpClass();
+ }
+
+ public BeanValidatorDetectorTest() {
+ // prefer do tests on target copy instead of original files
+ super(new File(basedir, "target" + File.separator + "classes"), Identity.class, Model.class);
+ }
+
+ @Override
+ protected void assertDetect(SortedSet<BeanValidator<?>> validators) {
+ assertFalse(validators.isEmpty());
+ assertEquals(2, validators.size());
+ Iterator<BeanValidator<?>> itrV = validators.iterator();
+ assertValidator(Identity.class, null, itrV.next());
+ assertValidator(Model.class, null, itrV.next());
+ }
+}
Property changes on: trunk/jaxx-demo/src/test/java/jaxx/demo/BeanValidatorDetectorTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
1
0
r1551 - trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation
by tchemit@users.nuiton.org 03 Oct '09
by tchemit@users.nuiton.org 03 Oct '09
03 Oct '09
Author: tchemit
Date: 2009-10-04 01:07:51 +0200 (Sun, 04 Oct 2009)
New Revision: 1551
Added:
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
Modified:
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
- deprecate none context safe navigation methods
- add two helper classes which are context safe and more friendly
Added: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (rev 0)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-03 23:07:51 UTC (rev 1551)
@@ -0,0 +1,133 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+
+/**
+ * To help getting and setting navigation tree objects from a {@link JAXXContext}.
+ * <p/>
+ * There is four type of data which can be hold in a context :
+ * <ul>
+ * <li>tree model : the navigation tree model</li>
+ * <li>tree handler : the navigation tree handler</li>
+ * <li>selected path : the navigation path of the selected node</li>
+ * <li>selected node : the selected node</li>
+ * <li>selected bean : the selected bean</li>
+ * </ul>
+ *
+ * To make possible the use of more than one navigation tree system in a same
+ * context, we <b>MUST</b> distinguish the context entries definition. For this
+ * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}.
+ * <p/>
+ * Here is the keys used :
+ * <ul>
+ * <li>tree model : {@code prefix + "-tree-model"}</li>
+ * <li>tree handler : {@code prefix + "-tree-handler"}</li>
+ * <li>selected path : {@code prefix + "-selected-path"}</li>
+ * <li>selected node : {@code prefix + "-selected-node"}</li>
+ * <li>selected bean : {@code prefix + "-selected-bean"}</li>
+ * </ul>
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeContextHelper {
+
+ protected final String prefix;
+ protected JAXXContextEntryDef<String> selectedPathContextEntry;
+ protected JAXXContextEntryDef<Object> selectedBeanContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry;
+
+ public NavigationTreeContextHelper(String contextPrefix) {
+ this.prefix = contextPrefix;
+ treeModelContextEntry = JAXXContextEntryDef.newDef(contextPrefix + "-tree-model", NavigationTreeModel.class);
+ treeHandlerContextEntry = JAXXContextEntryDef.newDef(contextPrefix + "-tree-handler", NavigationTreeHandler.class);
+ selectedBeanContextEntry = JAXXContextEntryDef.newDef(contextPrefix + "-selected-bean", Object.class);
+ selectedNodeContextEntry = JAXXContextEntryDef.newDef(contextPrefix + "-selected-node", NavigationTreeNode.class);
+ selectedPathContextEntry = JAXXContextEntryDef.newDef(contextPrefix + "-selected-path", String.class);
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public NavigationTreeModel getTreeModel(JAXXContext context) {
+ NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeHandler getTreeHandler(JAXXContext context) {
+ NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public String getSelectedPath(JAXXContext context) {
+ String r = getSelectedPathContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeNode getSelectedNode(JAXXContext context) {
+ NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public Object getSelectedBean(JAXXContext context) {
+ Object r = getSelectedBeanContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public void setTreeModel(JAXXContext context, NavigationTreeModel model) {
+ getTreeModelContextEntry().setContextValue(context, model);
+ }
+
+ public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) {
+ getTreeHandlerContextEntry().setContextValue(context, handler);
+ }
+
+ public void setSelectedPath(JAXXContext context, String path) {
+ if (path == null) {
+ getSelectedPathContextEntry().removeContextValue(context);
+ } else {
+ getSelectedPathContextEntry().setContextValue(context, path);
+ }
+ }
+
+ public void setSelectedNode(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ getSelectedNodeContextEntry().removeContextValue(context);
+ } else {
+ getSelectedNodeContextEntry().setContextValue(context, node);
+ }
+ }
+
+ public void setSelectedBean(JAXXContext context, Object bean) {
+ if (bean == null) {
+ getSelectedBeanContextEntry().removeContextValue(context);
+ } else {
+ getSelectedBeanContextEntry().setContextValue(context, bean);
+ }
+ }
+
+ public JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() {
+ return treeModelContextEntry;
+ }
+
+ public JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() {
+ return treeHandlerContextEntry;
+ }
+
+ public JAXXContextEntryDef<Object> getSelectedBeanContextEntry() {
+ return selectedBeanContextEntry;
+ }
+
+ public JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() {
+ return selectedNodeContextEntry;
+ }
+
+ public JAXXContextEntryDef<String> getSelectedPathContextEntry() {
+ return selectedPathContextEntry;
+ }
+}
Property changes on: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-03 23:06:18 UTC (rev 1550)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-03 23:07:51 UTC (rev 1551)
@@ -26,29 +26,69 @@
*/
public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel {
+ public static final String DEFAULT_CONTEXT_PREFIX = "navigation";
private static final long serialVersionUID = 1L;
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(NavigationTreeHandler.class);
+ /**
+ * @deprecated since 1.7.2, is no more used (prefer use the dynamic context entry defs)
+ */
+ @Deprecated
static public final String NAVIGATION_SELECTED_BEAN = "navigation-selected-bean";
+ /**
+ * @deprecated since 1.7.2, is no more used (prefer use the dynamic context entry defs)
+ */
+ @Deprecated
static public final JAXXContextEntryDef<String> NAVIGATION_SELECTED_PATH_ENTRY_DEF = JAXXContextEntryDef.newDef("navigation-selected-path", String.class);
+ /**
+ * @deprecated since 1.7.2, is no more used (prefer use the dynamic context entry defs)
+ */
+ @Deprecated
static public final JAXXContextEntryDef<NavigationTreeNode> NAVIGATION_SELECTED_NODE_ENTRY_DEF = JAXXContextEntryDef.newDef("navigation-selected-node", NavigationTreeNode.class);
- /** defined the stategy of instanciation of ui */
+ /**
+ * Define the stategy of instanciation of ui
+ */
public enum Strategy {
- /** instanciate a ui for a node */
+ /**
+ * instanciate a ui for a node
+ */
PER_NODE,
- /** instanciate only one a ui for a type,nodes will share the instanciation */
+ /**
+ * instanciate only one a ui for a type,nodes will share the instanciation
+ */
PER_UI_TYPE
}
- /** la classe d'ui par defaut, associé à un noeud de l'arbe */
+ /**
+ * default ui class to use if node does not define an ui class
+ */
protected Class<? extends JAXXObject> defaultUIClass;
+ /**
+ * [optional] default action class
+ */
protected Class<? extends JAXXAction> defaultUIHandlerClass;
- /** l'ui contenant l'arbre de navigation */
+ /**
+ * UI which contains navigation tree
+ */
protected JAXXObject context;
+ /**
+ * UI Instanciation strategy
+ */
protected Strategy strategy;
+ /**
+ * JAXXContext access helper.
+ *
+ * @since 1.7.2
+ */
+ protected NavigationTreeContextHelper contextHelper;
protected NavigationTreeHandler(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context, Strategy strategy) {
+ this(DEFAULT_CONTEXT_PREFIX, defaultUIClass, defaultUIHandlerClass, context, strategy);
+ }
+
+ protected NavigationTreeHandler(String contextPrefix, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context, Strategy strategy) {
+ this.contextHelper = new NavigationTreeContextHelper(contextPrefix);
this.defaultUIClass = defaultUIClass;
this.defaultUIHandlerClass = defaultUIHandlerClass;
this.context = context;
@@ -67,11 +107,14 @@
});
}
+ /**
+ * @return le modèle de navigation associé
+ */
protected abstract NavigationTreeModel getNavigationTreeModel();
/**
- * @return le composent actuellement visible associé au noeud courant ou au noeud précédent
- * lors d'un changement de noeud.
+ * @return le composent actuellement visible associé au noeud courant ou
+ * au noeud précédent lors d'un changement de noeud.
*/
protected abstract Component getCurrentUI();
@@ -97,6 +140,13 @@
*/
protected abstract Component createUI(NavigationTreeNode node) throws Exception;
+ /**
+ * Prepare le context a utiliser pour initialiser une nouvelle ui.
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return le context à utiliser pour instancier l'ui
+ * @throws Exception if any
+ */
protected abstract JAXXContext createUIContext(NavigationTreeNode node) throws Exception;
/**
@@ -196,10 +246,12 @@
}
// save in context current node context path
- NAVIGATION_SELECTED_PATH_ENTRY_DEF.setContextValue(context, node.getContextPath());
+ getContextHelper().setSelectedPath(context, node.getContextPath());
+// NAVIGATION_SELECTED_PATH_ENTRY_DEF.setContextValue(context, node.getContextPath());
// save in context current node
- NAVIGATION_SELECTED_NODE_ENTRY_DEF.setContextValue(context, node);
+ getContextHelper().setSelectedNode(context, node);
+// NAVIGATION_SELECTED_NODE_ENTRY_DEF.setContextValue(context, node);
// really open the ui associated with the selected node
openUI(newUI, node);
@@ -218,10 +270,12 @@
log.debug("find data for contextPath <" + node.getContextPath() + "> : " + (data == null ? null : data.getClass()));
}
- context.removeContextValue(Object.class, NAVIGATION_SELECTED_BEAN);
+ getContextHelper().setSelectedBean(context, null);
+// context.removeContextValue(Object.class, NAVIGATION_SELECTED_BEAN);
if (data != null) {
- context.setContextValue(data, NAVIGATION_SELECTED_BEAN);
+ getContextHelper().setSelectedBean(context, data);
+// context.setContextValue(data, NAVIGATION_SELECTED_BEAN);
//todo should we not use this to avoid conflict in context ?
context.setContextValue(data);
}
@@ -246,4 +300,8 @@
JAXXAction action = jaxxActionClass.newInstance();
return action;
}
+
+ public NavigationTreeContextHelper getContextHelper() {
+ return contextHelper;
+ }
}
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-03 23:06:18 UTC (rev 1550)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-03 23:07:51 UTC (rev 1551)
@@ -42,6 +42,16 @@
*/
protected abstract CardLayout2 getContentLayout();
+ public NavigationTreeHandlerWithCardLayout(String contextPrefix, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context, Strategy strategy) {
+ super(contextPrefix, defaultUIClass, defaultUIHandlerClass, context, strategy);
+ if (getContentContainer() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context);
+ }
+ if (getContentLayout() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context);
+ }
+ }
+
public NavigationTreeHandlerWithCardLayout(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context, Strategy strategy) {
super(defaultUIClass, defaultUIHandlerClass, context, strategy);
Added: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (rev 0)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-03 23:07:51 UTC (rev 1551)
@@ -0,0 +1,123 @@
+package jaxx.runtime.swing.navigation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Pattern;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Helper object associated to a given navigation tree system.
+ *
+ * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
+ *
+ * @author chemit
+ * @since 1.7.2
+ * @see NavigationTreeCellRenderer
+ */
+public abstract class NavigationTreeHelper extends NavigationTreeContextHelper {
+
+ static private final Log log = LogFactory.getLog(NavigationTreeHelper.class);
+
+ public abstract NavigationTreeModel createTreeModel(JAXXContext context);
+
+ public abstract NavigationTreeHandler createTreeHandler(JAXXObject context);
+
+ public NavigationTreeHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+
+ public Object getContextValue(JAXXContext context, String navigationPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.getJAXXContextValue(context, navigationPath);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String navigationPath) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(navigationPath);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String navigationPath, String regex) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(navigationPath, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String navigationPath, Pattern regex) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(navigationPath, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String navigationPath, String regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(navigationPath, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String navigationPath, Pattern regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(navigationPath, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation à partir de son path.
+ *
+ * @param context le contexte applicatif
+ * @param tree l'arbre
+ * @param contextPath le path absolue du noeud dans l'arbre
+ */
+ public void selectNode(JAXXContext context, JTree tree, String contextPath) {
+ NavigationTreeNode node = findNode(context, contextPath);
+ if (log.isDebugEnabled()) {
+ log.debug(contextPath + " :: " + node);
+ }
+ if (node != null) {
+ selectNode(context, tree, node);
+ }
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation.
+ *
+ * @param context le contexte applicatif
+ * @param tree l'arbre
+ * @param node le noeud à sélectionner dans l'arbre
+ */
+ public void selectNode(JAXXContext context, JTree tree, NavigationTreeNode node) {
+
+ NavigationTreeModel navigationModel = getSafeTreeModel(context);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ TreePath path = new TreePath(navigationModel.getPathToRoot(node));
+ tree.setSelectionPath(path);
+ tree.scrollPathToVisible(path);
+ if (!node.isLeaf() && !tree.isExpanded(path)) {
+ // expand the node to avoid a click :)
+ tree.expandPath(path);
+ }
+ }
+
+ public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException {
+ NavigationTreeModel treeModel = getTreeModel(context);
+ if (treeModel == null) {
+ throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context);
+ }
+ return treeModel;
+ }
+}
Property changes on: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2009-10-03 23:06:18 UTC (rev 1550)
+++ trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2009-10-03 23:07:51 UTC (rev 1551)
@@ -13,27 +13,77 @@
/**
* Usefull methods on {@link NavigationTreeModel} and others.
*
+ * The class is deprecated since it is not safe context, and can not be used
+ * with more than one navigation tree in a same context.
+ *
+ * Now use the {@link NavigationTreeContextHelper} and {@link NavigationTreeHelper}
+ * which are context safe and more friendly.
+ *
* @author chemit
+ *
* @see jaxx.runtime.swing.navigation.NavigationTreeModel
* @see jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode
+ *
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper} or
+ * {@link NavigationTreeContextHelper} to access data releated to a tree navigation
*/
+@Deprecated
public class NavigationUtil {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(NavigationUtil.class);
+ /**
+ *
+ * @param context
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeContextHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static String getCurrentNavigationNath(JAXXContext context) {
return NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_PATH_ENTRY_DEF.getContextValue(context);
}
+ /**
+ *
+ * @param context
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeContextHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static NavigationTreeNode getSelectedNode(JAXXContext context) {
return NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_NODE_ENTRY_DEF.getContextValue(context);
}
+ /**
+ *
+ * @param <O>
+ * @param context
+ * @param clazz
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeContextHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static <O> O getSelectedBean(JAXXContext context, Class<O> clazz) {
return context.getContextValue(clazz, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
}
+ /**
+ *
+ * @param context
+ * @param contextKey
+ * @param navigationPath
+ * @return
+ * @throws InvocationTargetException
+ * @throws NoSuchMethodException
+ * @throws IllegalAccessException
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static Object getContextValue(JAXXContext context, String contextKey, String navigationPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
@@ -41,6 +91,16 @@
return navigationModel.getJAXXContextValue(context, navigationPath);
}
+ /**
+ *
+ * @param context
+ * @param contextKey
+ * @param navigationPath
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static NavigationTreeNode findNode(JAXXContext context, String contextKey, String navigationPath) {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
@@ -48,6 +108,17 @@
return navigationModel.findNode(navigationPath);
}
+ /**
+ *
+ * @param context
+ * @param contextKey
+ * @param navigationPath
+ * @param regex
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static NavigationTreeNode findNode(JAXXContext context, String contextKey, String navigationPath, String regex) {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
@@ -55,7 +126,17 @@
return navigationModel.findNode(navigationPath, regex);
}
-
+ /**
+ *
+ * @param context
+ * @param contextKey
+ * @param navigationPath
+ * @param regex
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static NavigationTreeNode findNode(JAXXContext context, String contextKey, String navigationPath, Pattern regex) {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
@@ -63,6 +144,18 @@
return navigationModel.findNode(navigationPath, regex);
}
+ /**
+ *
+ * @param context
+ * @param contextKey
+ * @param navigationPath
+ * @param regex
+ * @param suffix
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static NavigationTreeNode findNode(JAXXContext context, String contextKey, String navigationPath, String regex, String suffix) {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
@@ -74,6 +167,18 @@
return navigationTreeNode;
}
+ /**
+ *
+ * @param context
+ * @param contextKey
+ * @param navigationPath
+ * @param regex
+ * @param suffix
+ * @return
+ * @deprecated since 1.7.2, prefer use a {@link NavigationTreeHelper}
+ * to access data releated to a tree navigation
+ */
+ @Deprecated
public static NavigationTreeNode findNode(JAXXContext context, String contextKey, String navigationPath, Pattern regex, String suffix) {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
@@ -96,7 +201,7 @@
protected Class<?> internalClass;
protected String rendererCachedValue;
-
+
private static final long serialVersionUID = -1238962588426200861L;
public NodeRenderer(String libelle) {
1
0