Author: tchemit Date: 2009-10-24 13:32:31 +0200 (Sat, 24 Oct 2009) New Revision: 1590 Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.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 Log: amelioration demo du NavigationTreeHandler Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx 2009-10-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx 2009-10-24 11:32:31 UTC (rev 1590) @@ -26,9 +26,13 @@ <script><![CDATA[ import jaxx.runtime.SwingUtil; +import jaxx.demo.component.jaxx.navigation.content.*; private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper(); +private final ContentUIHandler contentUIHandler = new ContentUIHandler(); setContextValue(helper); +setContextValue(contentUIHandler); +helper.setTree(this, navigation); helper.createModel(this); @Override Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2009-10-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2009-10-24 11:32:31 UTC (rev 1590) @@ -18,7 +18,7 @@ <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* --> -<JPanel layout='{new BorderLayout()}' implements='jaxx.runtime.swing.navigation.NavigationContentUI'> +<ContentUI superGenericType='People'> <script><![CDATA[ import jaxx.runtime.SwingUtil; @@ -27,61 +27,27 @@ @Override public void openUI(NavigationTreeNode node) throws Exception { - People p = (People) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + People p = (People) getHelper().getSelectedBean(this); log.info("selected people = "+p); setData(p); } -@Override -public void closeUI(NavigationTreeNode node) throws Exception { -// nothing to do -} - -String getType(Object data) { +String getContent(People 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); - } + 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; +ImageIcon getImage(People data) { + return data == null? null :SwingUtil.createIcon(data.getImage()); } - ]]> +]]> </script> - <People id='data' javaBean='(People) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this)'/> + <People id='data' javaBean='null'/> <JSplitPane id='splitPane' orientation='{JSplitPane.VERTICAL_SPLIT}' @@ -92,7 +58,7 @@ <JScrollPane border='{null}' horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}' + <JTextPane border='{new TitledBorder(_("jaxxdemo.navigation.actor.title"))}' editable='false' font-size='11' text='{getContent(getData())}'/> @@ -108,4 +74,4 @@ </JScrollPane> </JSplitPane> -</JPanel> \ No newline at end of file +</ContentUI> \ No newline at end of file Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2009-10-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2009-10-24 11:32:31 UTC (rev 1590) @@ -18,7 +18,7 @@ <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* --> -<JPanel layout='{new BorderLayout()}' implements='jaxx.runtime.swing.navigation.NavigationContentUI'> +<ContentUI superGenericType='java.util.List<People>'> <script><![CDATA[ import jaxx.runtime.SwingUtil; @@ -29,60 +29,42 @@ @Override public void openUI(NavigationTreeNode node) throws Exception { - java.util.List<People> ps = (java.util.List<People>)getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + java.util.List<People> ps = (java.util.List<People>)getHelper().getSelectedBean(this); log.info("selected peoples = "+ps.size()); setData(ps); + if (ps!=null) { + DefaultListModel model = (DefaultListModel) list.getModel(); + for (People p : ps) { + model.addElement(p); + } + } } @Override public void closeUI(NavigationTreeNode node) throws Exception { -// nothing to do + // clean list model + DefaultListModel model = (DefaultListModel) list.getModel(); + model.removeAllElements(); } - -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(); -} - -ListModel getModel(java.util.List<People> data) { - - DefaultListModel model = new DefaultListModel(); - for (People m : data) { - model.addElement(m); - } - return model; -} - ]]> </script> - <java.util.List id='data' - genericType='People' - javaBean='(java.util.List<People>)getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this)'/> + <java.util.List id='data' genericType='People' javaBean='null'/> - <JScrollPane border='{new TitledBorder("Content Type : " + getType(getData()))}' + <JScrollPane border='{new TitledBorder(_("jaxxdemo.navigation.actors.title"))}' constraints='BorderLayout.CENTER' columnHeaderView='{toolbar}' horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JList id='list' model='{getModel(getData())}' cellRenderer='{new DecoratorListCellRenderer(DecoratorUtils.get(People.class.getSimpleName()))}'/> + <JList id='list' model='{new DefaultListModel()}' cellRenderer='{new DecoratorListCellRenderer(DecoratorUtils.get(People.class.getSimpleName()))}'/> </JScrollPane> <JToolBar id='toolbar' constraints='BorderLayout.SOUTH' floatable='false'> <JPanel layout='{new GridLayout(1,0)}'> - <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}'/> + <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}' onActionPerformed='getHandler().selectChild(this, list.getSelectedIndex())'/> <JButton text='jaxxdemo.action.add'/> <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> </JPanel> </JToolBar> -</JPanel> \ No newline at end of file +</ContentUI> \ No newline at end of file Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUI.jaxx 2009-10-24 11:32:31 UTC (rev 1590) @@ -0,0 +1,52 @@ +<!-- + *##% + 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 abstract='true' + layout='{new BorderLayout()}' + genericType='B extends Object' + implements='NavigationContentUI'> + + <script><![CDATA[ +import jaxx.runtime.SwingUtil; +import jaxx.demo.component.jaxx.navigation.*; +import jaxx.runtime.decorator.DecoratorUtils; +import jaxx.runtime.decorator.swing.DecoratorListCellRenderer; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.runtime.swing.navigation.NavigationContentUI; + +ContentUIHandler getHandler() { + return getContextValue(ContentUIHandler.class); +} + +FullNavigationTreeHelper getHelper() { + return getContextValue(FullNavigationTreeHelper.class); +} + +public abstract B getData(); + +public abstract void setData(B data); + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { + // nothing to do +} + ]]> + </script> +</JPanel> \ No newline at end of file Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java 2009-10-24 11:32:31 UTC (rev 1590) @@ -0,0 +1,28 @@ +package jaxx.demo.component.jaxx.navigation.content; + +import java.util.List; +import jaxx.demo.component.jaxx.navigation.FullNavigationTreeHelper; +import jaxx.demo.component.jaxx.navigation.Movie; +import jaxx.demo.component.jaxx.navigation.People; +import jaxx.runtime.JAXXContext; + +/** + * + * @author chemit + */ +public class ContentUIHandler { + + public void selectChild(JAXXContext context, int movieIndex) { + FullNavigationTreeHelper helper = context.getContextValue(FullNavigationTreeHelper.class); + helper.gotoChildNode(context, movieIndex); + } + + public void addMovie(JAXXContext context, Movie movie) { + List<Movie> movies = FullNavigationTreeHelper.MOVIES.getContextValue(context); + List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(context); + } + + public void addActor(JAXXContext context, People a, Movie... movies) { + List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(context); + } +} Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ContentUIHandler.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2009-10-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2009-10-24 11:32:31 UTC (rev 1590) @@ -18,7 +18,7 @@ <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* --> -<JPanel layout='{new BorderLayout()}' implements='jaxx.runtime.swing.navigation.NavigationContentUI'> +<ContentUI superGenericType='Movie'> <script><![CDATA[ import jaxx.runtime.SwingUtil; @@ -27,61 +27,27 @@ @Override public void openUI(NavigationTreeNode node) throws Exception { - Movie m = (Movie) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); - log.info("selected movie = "+m); + Movie m = (Movie) getHelper().getSelectedBean(this); + log.info("selected movie = " + m); setData(m); } -@Override -public void closeUI(NavigationTreeNode node) throws Exception { -// nothing to do -} - -String getType(Object data) { +String getContent(Movie 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); - } + 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; +ImageIcon getImage(Movie data) { + return data == null? null :SwingUtil.createIcon(data.getImage()); } - ]]> +]]> </script> - <Movie id='data' javaBean='(Movie) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this)'/> + <Movie id='data' javaBean='null'/> <JSplitPane id='splitPane' orientation='{JSplitPane.VERTICAL_SPLIT}' @@ -92,7 +58,7 @@ <JScrollPane border='{null}' horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}' + <JTextPane border='{new TitledBorder(_("jaxxdemo.navigation.movie.title"))}' editable='false' font-size='11' text='{getContent(getData())}'/> @@ -108,4 +74,4 @@ </JScrollPane> </JSplitPane> -</JPanel> \ No newline at end of file +</ContentUI> \ No newline at end of file Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2009-10-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2009-10-24 11:32:31 UTC (rev 1590) @@ -18,7 +18,7 @@ <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* --> -<JPanel layout='{new BorderLayout()}' implements='jaxx.runtime.swing.navigation.NavigationContentUI'> +<ContentUI superGenericType='java.util.List<Movie>'> <script><![CDATA[ import jaxx.runtime.SwingUtil; @@ -29,58 +29,42 @@ @Override public void openUI(NavigationTreeNode node) throws Exception { - java.util.List<Movie> ms = (java.util.List<Movie>)getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + java.util.List<Movie> ms = (java.util.List<Movie>)getHelper().getSelectedBean(this); log.info("selected movies = "+ms.size()); setData(ms); + if (ms != null) { + DefaultListModel model = (DefaultListModel) list.getModel(); + for (Movie m : ms) { + model.addElement(m); + } + } } @Override public void closeUI(NavigationTreeNode node) throws Exception { -// nothing to do + // clean list model + DefaultListModel model = (DefaultListModel) list.getModel(); + model.removeAllElements(); } -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(); -} - -ListModel getModel(java.util.List<Movie> data) { - DefaultListModel model = new DefaultListModel(); - for (Movie m : data) { - model.addElement(m); - } - return model; -} - ]]> </script> - <java.util.List id='data' - genericType='Movie' - javaBean='(java.util.List<Movie>)getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this)'/> + <java.util.List id='data' genericType='Movie' javaBean='null'/> - <JScrollPane border='{new TitledBorder("Content Type : " + getType(getData()))}' + <JScrollPane border='{new TitledBorder(_("jaxxdemo.navigation.movies.title"))}' constraints='BorderLayout.CENTER' columnHeaderView='{toolbar}' horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}' verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'> - <JList id='list' model='{getModel(getData())}' cellRenderer='{new DecoratorListCellRenderer(DecoratorUtils.get(Movie.class.getSimpleName()))}'/> + <JList id='list' model='{new DefaultListModel()}' cellRenderer='{new DecoratorListCellRenderer(DecoratorUtils.get(Movie.class.getSimpleName()))}'/> </JScrollPane> <JToolBar id='toolbar' opaque='false' constraints='BorderLayout.SOUTH' floatable='false'> <JPanel layout='{new GridLayout(1,0)}'> - <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}'/> + <JButton text='jaxxdemo.action.show' enabled='{list.getSelectedIndex()!=-1}' onActionPerformed='getHandler().selectChild(this, list.getSelectedIndex())'/> <JButton text='jaxxdemo.action.add'/> <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> </JPanel> </JToolBar> -</JPanel> \ No newline at end of file +</ContentUI> \ No newline at end of file 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-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-24 11:32:31 UTC (rev 1590) @@ -159,6 +159,10 @@ jaxxdemo.menu.help= jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded. jaxxdemo.message.goto.site=Go to JAXXDemo Web site +jaxxdemo.navigation.actor.title= +jaxxdemo.navigation.actors.title= +jaxxdemo.navigation.movie.title= +jaxxdemo.navigation.movies.title= jaxxdemo.numbereditor.autoPopup= jaxxdemo.numbereditor.configuration= jaxxdemo.numbereditor.model= 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-24 11:31:57 UTC (rev 1589) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-24 11:32:31 UTC (rev 1590) @@ -159,6 +159,10 @@ 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.navigation.actor.title= +jaxxdemo.navigation.actors.title= +jaxxdemo.navigation.movie.title= +jaxxdemo.navigation.movies.title= jaxxdemo.numbereditor.autoPopup=Affichage automatique popup jaxxdemo.numbereditor.configuration=Configuration jaxxdemo.numbereditor.model=R\u00E9sultat