Author: tchemit Date: 2009-10-23 18:44:44 +0200 (Fri, 23 Oct 2009) New Revision: 1586 Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ 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 Removed: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 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/FullNavigationTreeHelper.java 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: - add a contract NavigationContentUI and use it in NavigationTreeHandler - improve demo Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-10-23 16:44:44 UTC (rev 1586) @@ -26,6 +26,7 @@ import java.util.Locale; import java.util.Properties; +import jaxx.demo.component.jaxx.navigation.FullNavigationTreeDemo; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -110,6 +111,11 @@ return result; } + public String getDemoPath() { + String result = getOption(Option.DEMO_PATH.key); + return result; + } + public void setFullscreen(boolean fullscreen) { Object oldValue = null; setOption(Option.FULL_SCREEN.key, fullscreen + ""); @@ -159,7 +165,8 @@ 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); + LOCALE("ui.locale", _("jaxxdemo.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false), + DEMO_PATH("ui.demo.path", _("jaxxdemo.config.ui.demo.path"), "$root/jaxxdemo.tree.component.jaxx/jaxxdemo.tree.component.jaxx.tree.navigation/" + FullNavigationTreeDemo.class.getSimpleName(), String.class, false, false); public final String key; public final String description; public final String defaultValue; 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-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-23 16:44:44 UTC (rev 1586) @@ -93,7 +93,7 @@ return ui; } - public void displayUI(final DemoUI ui, final NavigationTreeNode node) { + public void displayUI(final DemoUI ui, final String nodePath) { // expend all nodes of the demo tree jaxx.runtime.SwingUtil.expandTree(ui.getNavigation()); @@ -104,12 +104,12 @@ public void run() { String path; - if (node == null) { + if (nodePath == null) { // take first node path = "$root/jaxxdemo.tree.component.swing"; } else { // take selected node - path = node.getFullPath(); + path = nodePath; } log.info("node to re select " + path); // select node @@ -146,6 +146,7 @@ DemoUI ui = getUI(rootContext); NavigationTreeNode node = null; + String nodePath = null; if (ui != null) { @@ -154,7 +155,8 @@ node = ui.getTreeHelper().getSelectedNode(ui); if (node != null) { - log.info("selected node " + node.getFullPath()); + nodePath = node.getFullPath(); + log.info("selected node " + nodePath); } ErrorDialogUI.init(null); @@ -169,7 +171,7 @@ ui = initUI(rootContext, fullscreen); - displayUI(ui, node); + displayUI(ui, nodePath); } /** Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-23 16:44:44 UTC (rev 1586) @@ -119,7 +119,7 @@ log.info(_("jaxxdemo.init.ui.done")); - handler.displayUI(ui, null); + handler.displayUI(ui, config.getDemoPath()); } catch (Exception e) { ErrorDialogUI.showError(e); Deleted: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx 2009-10-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx 2009-10-23 16:44:44 UTC (rev 1586) @@ -1,99 +0,0 @@ -<!-- - *##% - 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 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-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx 2009-10-23 16:44:44 UTC (rev 1586) @@ -28,12 +28,12 @@ import jaxx.runtime.SwingUtil; private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper(); - +setContextValue(helper); helper.createModel(this); @Override protected String[] getSources() { - return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" }; + return new String[]{ getDefaultSource(), "FullNavigationTreeHelper.java", "Movie.java", "People.java" }; } private void $afterCompleteSetup() { Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-23 16:44:44 UTC (rev 1586) @@ -23,7 +23,6 @@ import jaxx.runtime.JAXXObject; import jaxx.runtime.JAXXContext; import jaxx.runtime.context.JAXXContextEntryDef; -import jaxx.runtime.decorator.Decorator; import jaxx.runtime.decorator.DecoratorUtils; import jaxx.runtime.swing.CardLayout2; import jaxx.runtime.swing.ErrorDialogUI; @@ -31,13 +30,10 @@ import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy; import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout; import jaxx.runtime.swing.navigation.NavigationTreeHelper; -import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; -import jaxx.runtime.swing.navigation.NavigationTreeNode; import jaxx.runtime.swing.navigation.NavigationTreeModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import static org.nuiton.i18n.I18n._; import java.util.Arrays; import java.util.List; @@ -74,6 +70,7 @@ * where the actors are hold in context */ static public final JAXXContextEntryDef<List<People>> ACTORS = Util.newListContextEntryDef("actors"); + protected FullNavigationTreeModelBuilder builder; public FullNavigationTreeHelper() { super("full"); @@ -85,6 +82,7 @@ * @param context the context where to hold the model */ public void createModel(JAXXContext context) { + log.info("for " + this); 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"); @@ -105,87 +103,14 @@ @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)"); + if (builder == null) { + builder = new FullNavigationTreeModelBuilder(context); } - NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/", context, BaseContent.class, - null); + builder.createInitialModel(); - 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"), - 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"), - 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; @@ -203,7 +128,7 @@ handler = new NavigationTreeHandlerWithCardLayout( getPrefix(), context, - Strategy.PER_NODE) { + Strategy.PER_UI_TYPE) { private static final long serialVersionUID = 1L; Added: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java 2009-10-23 16:44:44 UTC (rev 1586) @@ -0,0 +1,120 @@ +package jaxx.demo.component.jaxx.navigation; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.decorator.Decorator; +import jaxx.runtime.decorator.DecoratorUtils; +import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import jaxx.demo.component.jaxx.navigation.content.*; +import static org.nuiton.i18n.I18n._; + +import java.util.List; + +/** + * + * @author chemit + * @since 2.0.0 + */ +public class FullNavigationTreeModelBuilder extends NavigationTreeModelBuilder { + + private static final long serialVersionUID = 1l; + /** + * Logger + */ + static private final Log log = LogFactory.getLog(FullNavigationTreeModelBuilder.class); + + protected FullNavigationTreeModelBuilder(JAXXContext context) { + super("/", context, null, null); + } + + public void addMovie(Movie movie) { + //TODO + } + + public void addActor(People people,Movie... movies) { + //TODO + } + + public void createInitialModel() { + + List<Movie> movies = FullNavigationTreeHelper.MOVIES.getContextValue(getModel().getContext()); + List<People> actors = FullNavigationTreeHelper.ACTORS.getContextValue(getModel().getContext()); + + if (log.isDebugEnabled()) { + log.debug("for " + movies.size() + " movie(s)"); + } + + + 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 = this.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 = this.build( + rootNode, + _("movies"), + FullNavigationTreeHelper.MOVIES, + "movies", + MoviesContentUI.class, + null); + + for (Movie m : movies) { + + // navigation path = $root/movies/m.id + NavigationTreeNode movieNode = this.build( + moviesNode, + mDecorator, + "..[@id=\"" + m.getId() + "\"]", + m.getId(), + MovieContentUI.class, + null); + + // navigation path = $root/movies/m.id/actors + NavigationTreeNode actorsNode = this.build( + movieNode, + _("actors"), + "../actors", + "actors", + ActorsContentUI.class, + null); + + for (People p : m.getActors()) { + // navigation path = $root/movies/m.id/actors/p.id + this.build( + actorsNode, + pDecorator, + "..[@id=\"" + p.getId() + "\"]", + p.getId(), + ActorContentUI.class, + null); + } + } + + // construction du noeud avec les acteurs + NavigationTreeNode actorsNode = this.build(rootNode, _("actors"), + FullNavigationTreeHelper.ACTORS, + "actors", ActorsContentUI.class, null); + + for (People p : actors) { + // navigation path = $root/actors/p.id + this.build( + actorsNode, + pDecorator, + "..[@id=\"" + p.getId() + "\"]", + p.getId(), + ActorContentUI.class, + null); + } + + if (log.isDebugEnabled()) { + printModel(getModel().getRoot()); + } + } +} Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeModelBuilder.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL Added: 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 (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorContentUI.jaxx 2009-10-23 16:44:44 UTC (rev 1586) @@ -0,0 +1,111 @@ +<!-- + *##% + 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()}' implements='jaxx.runtime.swing.navigation.NavigationContentUI'> + + <script><![CDATA[ +import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.demo.component.jaxx.navigation.*; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + People p = (People) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + log.info("selected people = "+p); + setData(p); +} + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { +// nothing to do +} + +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> + + <People id='data' javaBean='(People) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this)'/> + + <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/navigation/content/ActorsContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/ActorsContentUI.jaxx 2009-10-23 16:44:44 UTC (rev 1586) @@ -0,0 +1,88 @@ +<!-- + *##% + 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()}' implements='jaxx.runtime.swing.navigation.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; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + java.util.List<People> ps = (java.util.List<People>)getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + log.info("selected peoples = "+ps.size()); + setData(ps); +} + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { +// nothing to do +} + +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)'/> + + <JScrollPane border='{new TitledBorder("Content Type : " + getType(getData()))}' + 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()))}'/> + </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.add'/> + <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> + </JPanel> + </JToolBar> + +</JPanel> \ No newline at end of file Added: 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 (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MovieContentUI.jaxx 2009-10-23 16:44:44 UTC (rev 1586) @@ -0,0 +1,111 @@ +<!-- + *##% + 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()}' implements='jaxx.runtime.swing.navigation.NavigationContentUI'> + + <script><![CDATA[ +import jaxx.runtime.SwingUtil; +import jaxx.runtime.swing.navigation.NavigationTreeNode; +import jaxx.demo.component.jaxx.navigation.*; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + Movie m = (Movie) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + log.info("selected movie = "+m); + setData(m); +} + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { +// nothing to do +} + +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> + + <Movie id='data' javaBean='(Movie) getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this)'/> + + <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/navigation/content/MoviesContentUI.jaxx =================================================================== --- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx (rev 0) +++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/content/MoviesContentUI.jaxx 2009-10-23 16:44:44 UTC (rev 1586) @@ -0,0 +1,86 @@ +<!-- + *##% + 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()}' implements='jaxx.runtime.swing.navigation.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; + +@Override +public void openUI(NavigationTreeNode node) throws Exception { + java.util.List<Movie> ms = (java.util.List<Movie>)getContextValue(FullNavigationTreeHelper.class).getSelectedBean(this); + log.info("selected movies = "+ms.size()); + setData(ms); +} + +@Override +public void closeUI(NavigationTreeNode node) throws Exception { +// nothing to do +} +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)'/> + + <JScrollPane border='{new TitledBorder("Content Type : " + getType(getData()))}' + 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()))}'/> + </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.add'/> + <JButton text='jaxxdemo.action.remove' enabled='{list.getSelectedIndex()!=-1}'/> + </JPanel> + </JToolBar> + +</JPanel> \ 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-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-23 16:44:44 UTC (rev 1586) @@ -117,6 +117,7 @@ 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.add= jaxxdemo.action.configuration=Preferences jaxxdemo.action.configuration.tip=Change the preferences of the application jaxxdemo.action.exit=Quit @@ -131,6 +132,8 @@ 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.remove= +jaxxdemo.action.show= jaxxdemo.action.site=Web site jaxxdemo.action.site.tip=Go to the web site jaxxdemo.config.category.directories=Files @@ -138,6 +141,7 @@ jaxxdemo.config.category.other=Others jaxxdemo.config.category.other.description=Others preferences jaxxdemo.config.configFileName.description=Configuration file name +jaxxdemo.config.ui.demo.path= jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen) jaxxdemo.config.ui.locale=Locale of the application jaxxdemo.i18neditor.configuration=Configuration @@ -189,5 +193,6 @@ numbereditor.type=Type numbereditor.with.auto.popup=With auto popup numbereditor.without.auto.popup=Without auto popup +test= valid= x= 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-23 16:42:17 UTC (rev 1585) +++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-23 16:44:44 UTC (rev 1586) @@ -117,6 +117,7 @@ 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.add= jaxxdemo.action.configuration=Configuration jaxxdemo.action.configuration.tip=Modifier la configuration jaxxdemo.action.exit=Quitter @@ -131,6 +132,8 @@ 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.remove= +jaxxdemo.action.show= jaxxdemo.action.site=Site internet jaxxdemo.action.site.tip=Acc\u00E9der au site de l'application sur internet jaxxdemo.config.category.directories=R\u00E9pertoires @@ -138,6 +141,7 @@ 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.demo.path= 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.i18neditor.configuration=Configuration @@ -189,5 +193,6 @@ numbereditor.type=Type d'\u00E9diteur numbereditor.with.auto.popup=Avec popup auto numbereditor.without.auto.popup=Sans popup auto +test= valid=valide x=x