Author: chemit Date: 2008-12-01 14:56:55 +0000 (Mon, 01 Dec 2008) New Revision: 1044 Added: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java Removed: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationtreeSelectionAdapterWithCardLayout.java Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java lutinjaxx/trunk/pom.xml Log: rename mistake , ... Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-12-01 08:10:22 UTC (rev 1043) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-12-01 14:56:55 UTC (rev 1044) @@ -20,7 +20,7 @@ } public String toString(Object bean) { - //todo check bean class + //todo check bean class JXPathContext jxcontext = JXPathContext.newContext(bean); String result = (String) jxcontext.getValue(expression); if (log.isDebugEnabled()) { Copied: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java (from rev 1019, lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationtreeSelectionAdapterWithCardLayout.java) =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java (rev 0) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapterWithCardLayout.java 2008-12-01 14:56:55 UTC (rev 1044) @@ -0,0 +1,106 @@ +package jaxx.runtime.swing.navigation; + +import jaxx.runtime.JAXXAction; +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXInitialContext; +import jaxx.runtime.JAXXObject; +import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; +import jaxx.runtime.swing.CardLayout2; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.JPanel; +import javax.swing.event.TreeSelectionEvent; +import java.awt.Component; + +/** + * Simple {@link NavigationTreeSelectionAdapter} implementation with a {@link jaxx.runtime.swing.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 NavigationTreeSelectionAdapterWithCardLayout extends NavigationTreeSelectionAdapter { + + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private final Log log = LogFactory.getLog(NavigationTreeSelectionAdapterWithCardLayout.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 NavigationTreeSelectionAdapterWithCardLayout(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context) { + super(defaultUIClass, defaultUIHandlerClass, context); + + 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); + } + } + + protected Component getCurrentUI() { + CardLayout2 layout = getContentLayout(); + JPanel container = getContentContainer(); + return layout.getVisibleComponent(container); + } + + protected Component getNewUI(String path) { + CardLayout2 layout = getContentLayout(); + JPanel container = getContentContainer(); + return layout.contains(path) ? layout.getComponent(container, path) : null; + } + + protected void openUI(Component newUI, NavigationTreeNode node) throws Exception { + CardLayout2 layout = getContentLayout(); + JPanel container = getContentContainer(); + // switch layout + layout.show(container, node.getContextPath()); + } + + protected boolean closeUI(TreeSelectionEvent event, Component component) throws Exception { + // by default, we says that component was succesfull closed + return true; + } + + protected Component createUI(NavigationTreeNode node) throws Exception { + JAXXObject newUI; + + if (node.getJaxxActionClass() != null) { + JAXXAction action = node.getJaxxActionClass().newInstance(); + // init context with + JAXXInitialContext context = action.init(this.context); + // must instanciate the ui with an JAXXInitialContext + newUI = node.getJaxxClass().getConstructor(JAXXContext.class).newInstance(context); + } else { + if (log.isWarnEnabled()) { + log.warn("no action associated with ui " + node.getJaxxClass()); + } + // no action associated, just + newUI = node.getJaxxClass().getConstructor(JAXXContext.class).newInstance(this.context); + } + if (log.isDebugEnabled()) { + log.debug("instanciate new ui " + newUI); + } + + getContentContainer().add((Component) newUI, node.getContextPath()); + return (Component) newUI; + } +} + Deleted: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationtreeSelectionAdapterWithCardLayout.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationtreeSelectionAdapterWithCardLayout.java 2008-12-01 08:10:22 UTC (rev 1043) +++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationtreeSelectionAdapterWithCardLayout.java 2008-12-01 14:56:55 UTC (rev 1044) @@ -1,106 +0,0 @@ -package jaxx.runtime.swing.navigation; - -import jaxx.runtime.JAXXAction; -import jaxx.runtime.JAXXContext; -import jaxx.runtime.JAXXInitialContext; -import jaxx.runtime.JAXXObject; -import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode; -import jaxx.runtime.swing.CardLayout2; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.JPanel; -import javax.swing.event.TreeSelectionEvent; -import java.awt.Component; - -/** - * Simple {@link NavigationTreeSelectionAdapter} implementation with a {@link jaxx.runtime.swing.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 NavigationtreeSelectionAdapterWithCardLayout extends NavigationTreeSelectionAdapter { - - - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private final Log log = LogFactory.getLog(NavigationtreeSelectionAdapterWithCardLayout.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 NavigationtreeSelectionAdapterWithCardLayout(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, JAXXObject context) { - super(defaultUIClass, defaultUIHandlerClass, context); - - 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); - } - } - - protected Component getCurrentUI() { - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - return layout.getVisibleComponent(container); - } - - protected Component getNewUI(String path) { - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - return layout.contains(path) ? layout.getComponent(container, path) : null; - } - - protected void openUI(Component newUI, NavigationTreeNode node) throws Exception { - CardLayout2 layout = getContentLayout(); - JPanel container = getContentContainer(); - // switch layout - layout.show(container, node.getContextPath()); - } - - protected boolean closeUI(TreeSelectionEvent event, Component component) throws Exception { - // by default, we says that component was succesfull closed - return true; - } - - protected Component createUI(NavigationTreeNode node) throws Exception { - JAXXObject newUI; - - if (node.getJaxxActionClass() != null) { - JAXXAction action = node.getJaxxActionClass().newInstance(); - // init context with - JAXXInitialContext context = action.init(this.context); - // must instanciate the ui with an JAXXInitialContext - newUI = node.getJaxxClass().getConstructor(JAXXContext.class).newInstance(context); - } else { - if (log.isWarnEnabled()) { - log.warn("no action associated with ui " + node.getJaxxClass()); - } - // no action associated, just - newUI = node.getJaxxClass().getConstructor(JAXXContext.class).newInstance(this.context); - } - if (log.isDebugEnabled()) { - log.debug("instanciate new ui " + newUI); - } - - getContentContainer().add((Component) newUI, node.getContextPath()); - return (Component) newUI; - } -} - Modified: lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst =================================================================== --- lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst 2008-12-01 08:10:22 UTC (rev 1043) +++ lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst 2008-12-01 14:56:55 UTC (rev 1044) @@ -148,7 +148,7 @@ Si une erreur survient lors de ces opérations, on entre dans la méthode *goBackToPreviousNode* qui est abstraite et permet de notifier les erreur de retourner au noeud précdent. -jaxx.runtime.swing.navigation.NavigationtreeSelectionAdapterWithCardLayout +jaxx.runtime.swing.navigation.NavigationTreeSelectionAdapterWithCardLayout ************************************************************************** Il s'agit d'une implantation du listener précédent qui suppose que les uis associées aux noeuds sont affichées dans un Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java =================================================================== --- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-12-01 08:10:22 UTC (rev 1043) +++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/JXPathDecoratorTest.java 2008-12-01 14:56:55 UTC (rev 1044) @@ -35,13 +35,12 @@ @Test public void testDecorator() throws Exception { - //fixme : make me works :) - - //Decorator<Model> decorator = new JXPathDecorator<Model>("./name (./integerValue"); + //fixme : make me work :) + Decorator<Model> decorator = new JXPathDecorator<Model>(Model.class,"${name} - ${integerValue}"); - //Model m = new Model("name", 10); - //String expected = m.getName() + " (" + m.getIntegervalue() + ")"; - //String result = decorator.toString(m); + Model m = new Model("name", 10); +// String expected = m.getName() + " - " + m.getIntegervalue(); +// String result = decorator.toString(m); //org.junit.Assert.assertEquals(expected, result); } Modified: lutinjaxx/trunk/pom.xml =================================================================== --- lutinjaxx/trunk/pom.xml 2008-12-01 08:10:22 UTC (rev 1043) +++ lutinjaxx/trunk/pom.xml 2008-12-01 14:56:55 UTC (rev 1044) @@ -58,17 +58,17 @@ <!-- override this property to define scm url property --> <scm.url.son> - http://${labs.host}/plugins/scmsvn/viewcvs.php/lutinjaxx/trunk/${pom.artifactId}/?root=${labs.project} + http://${labs.host}/plugins/scmsvn/viewcvs.php/lutinjaxx/trunk/${project.artifactId}/?root=${labs.project} </scm.url.son> <!-- BEWARE, will be suffixed by /${pom.artifactId} by inheritance --> <scm.developerConnection.son> - scm:svn:svn+ssh://${username}@${labs.host}/svnroot/${labs.project}/lutinjaxx/trunk/${pom.artifactId} + scm:svn:svn+ssh://${username}@${labs.host}/svnroot/${labs.project}/lutinjaxx/trunk/${project.artifactId} </scm.developerConnection.son> <!-- BEWARE, will be suffixed by /${pom.artifactId} by inheritance --> <scm.connection.son> - scm:svn:svn://anonymous@${labs.host}/svnroot/${labs.project}/lutinjaxx/trunk/${pom.artifactId} + scm:svn:svn://anonymous@${labs.host}/svnroot/${labs.project}/lutinjaxx/trunk/${project.artifactId} </scm.connection.son> </properties>