Author: sletellier Date: 2010-03-15 15:19:31 +0100 (Mon, 15 Mar 2010) New Revision: 1788 Log: - Adding simple clic selection handler - Adding docs - Set SelectionMode to discontiguous for multi selection Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java trunk/src/site/rst/NavigationModel.rst Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-15 12:17:04 UTC (rev 1787) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationMultiTreeHandler.java 2010-03-15 14:19:31 UTC (rev 1788) @@ -43,6 +43,8 @@ * from nodes we can not just listen selection model changed, we must control * it. * + * This one is used to enable multi selection + * * @author sletellier * @since 2.0.1 */ @@ -55,6 +57,9 @@ public NavigationMultiTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) { super(contextPrefix, context, strategy); + + // Enable multi selection + super.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); } @Override @@ -168,7 +173,7 @@ } } - public List<String> getPaths(List<NavigationTreeNode> nodes){ + protected List<String> getPaths(List<NavigationTreeNode> nodes){ List<String> result = new ArrayList<String>(); for (NavigationTreeNode node : nodes){ result.add(node.getFullPath()); Added: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java =================================================================== --- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java (rev 0) +++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationOneClicSelectionHandler.java 2010-03-15 14:19:31 UTC (rev 1788) @@ -0,0 +1,72 @@ +/* + * *##% + * JAXX Runtime + * 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.runtime.swing.navigation; + +import jaxx.runtime.JAXXContext; +import jaxx.runtime.JAXXObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTreeTable; + +import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; +import java.awt.Component; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * The handler of a navigation tree. + * + * This is also the selection model to use, since we must check before moving + * from nodes we can not just listen selection model changed, we must control + * it. + * + * This one is used to enable one clic multi selection + * + * @author sletellier + * @since 2.0.1 + */ +public abstract class NavigationOneClicSelectionHandler extends NavigationMultiTreeHandler { + /** + * Logger + */ + static private final Log log = LogFactory.getLog(NavigationOneClicSelectionHandler.class); + + + public NavigationOneClicSelectionHandler(String contextPrefix, JAXXObject context, NavigationTreeHandler.Strategy strategy) { + super(contextPrefix, context, strategy); + } + + @Override + public void setSelectionPath(TreePath path) { + TreePath[] treePaths = getSelectionPaths(); + if (treePaths == null || !Arrays.asList(treePaths).contains(path)){ + addSelectionPath(path); + } else { + removeSelectionPath(path); + } + } + +} Modified: trunk/src/site/rst/NavigationModel.rst =================================================================== --- trunk/src/site/rst/NavigationModel.rst 2010-03-15 12:17:04 UTC (rev 1787) +++ trunk/src/site/rst/NavigationModel.rst 2010-03-15 14:19:31 UTC (rev 1788) @@ -19,7 +19,7 @@ jaxx.runtime.swing.navigation.NavigationModel ============================================= -Contract représentant le model de l'arbre de navigation. +Contrat representant le model de l'arbre de navigation. Les noeuds présents dans se modèle sont aussi typés en *jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode*. @@ -104,6 +104,12 @@ Extension de *jaxx.runtime.swing.navigation.NavigationTreeHandler* pour ajouter la possibilité d'utiliser la multisélection. +jaxx.runtime.swing.navigation.NavigationOneClicSelectionHandler +--------------------------------------------------------------- + +Extension de *jaxx.runtime.swing.navigation.NavigationMultiTreeHandler* pour +activer le simple clic lors de la multi-selection. + Définition d'un noeud =====================