branch feature/7553_ajoute_un_widget_pour_les_arbres updated (d6f48d4 -> 352e407)
This is an automated email from the git hooks/post-receive script. New change to branch feature/7553_ajoute_un_widget_pour_les_arbres in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git from d6f48d4 Crée le composant BeanTreeHeader visant à offrir un group d'actions facilitant l'utilisation des composants arbre par l'utilisateur new 352e407 Implementation du comportement des boutons de la toolbar du BeanTreeHeader dans le handler The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 352e407720dab617258f463be4ce914b60a38502 Author: Samuel Maisonneuve <maisonneuve@codelutin.com> Date: Mon Aug 22 20:10:11 2016 +0200 Implementation du comportement des boutons de la toolbar du BeanTreeHeader dans le handler refs #7553 Summary of changes: observe-application-swing/pom.xml | 1 + .../ird/observe/ui/util/tree/BeanTreeHeader.jaxx | 24 +++----- .../ui/util/tree/BeanTreeHeaderHandler.java | 68 ++++++++++++++++++++-- 3 files changed, 71 insertions(+), 22 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/7553_ajoute_un_widget_pour_les_arbres in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 352e407720dab617258f463be4ce914b60a38502 Author: Samuel Maisonneuve <maisonneuve@codelutin.com> Date: Mon Aug 22 20:10:11 2016 +0200 Implementation du comportement des boutons de la toolbar du BeanTreeHeader dans le handler refs #7553 --- observe-application-swing/pom.xml | 1 + .../ird/observe/ui/util/tree/BeanTreeHeader.jaxx | 24 +++----- .../ui/util/tree/BeanTreeHeaderHandler.java | 68 ++++++++++++++++++++-- 3 files changed, 71 insertions(+), 22 deletions(-) diff --git a/observe-application-swing/pom.xml b/observe-application-swing/pom.xml index ed97561..56611b8 100644 --- a/observe-application-swing/pom.xml +++ b/observe-application-swing/pom.xml @@ -52,6 +52,7 @@ ${project.basedir}/src/main/java/fr/ird/observe/ui/ObserveCommon.jcss </jaxx.commonCss> <jaxx.cssExtension>jcss</jaxx.cssExtension> + <jaxx.addAutoHandlerUI>true</jaxx.addAutoHandlerUI> <!-- main class in JAR --> <maven.jar.main.class>fr.ird.observe.ObserveAdminCLI</maven.jar.main.class> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeader.jaxx b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeader.jaxx index 6110ef1..4cf27ed 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeader.jaxx +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeader.jaxx @@ -19,31 +19,21 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JPanel id="beanTreeHeader" - layout='{new BorderLayout()}'> +<JPanel layout='{new BorderLayout()}'> - <BeanTreeHeaderHandler id='handler' constructorParams='this'/> - - <script><![CDATA[ - -void $afterCompleteSetup() { - getHandler().initUI(); -} - -]]> - </script> + <JTree id='tree' javaBean='new JTree()'/> <JLabel id="label" constraints='BorderLayout.CENTER'/> <JToolBar id='toolbar' constraints='BorderLayout.EAST'> <!-- les boutons pour grouper/déplier tout l'arbre --> - <JButton id='colapseAll'/> - <JButton id='expandAll'/> + <JButton id='colapseAll' onActionPerformed='handler.collapseAll()'/> + <JButton id='expandAll' onActionPerformed='handler.expandAll()'/> - <!-- les boutons pour sélectionner/déselctionner tout l'arbre --> - <JButton id='selectAll'/> - <JButton id='deselectAll'/> + <!-- les boutons pour sélectionner/déselectionner tout l'arbre --> + <JButton id='selectAll' onActionPerformed='handler.selectAll()'/> + <JButton id='deselectAll' onActionPerformed='handler.deselectAll()'/> </JToolBar> diff --git a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeaderHandler.java b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeaderHandler.java index e9d09a4..5dc51b8 100644 --- a/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeaderHandler.java +++ b/observe-application-swing/src/main/java/fr/ird/observe/ui/util/tree/BeanTreeHeaderHandler.java @@ -22,24 +22,82 @@ package fr.ird.observe.ui.util.tree; * #L% */ +import jaxx.runtime.spi.UIHandler; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; + /** * @author Samuel Maisonneuve- maisonneuve@codelutin.com */ -public class BeanTreeHeaderHandler { +public class BeanTreeHeaderHandler implements UIHandler<BeanTreeHeader> { private static final Log log = LogFactory.getLog(BeanTreeHeaderHandler.class); - private final BeanTreeHeader ui; + public BeanTreeHeader getUi() { + return ui; + } + + private BeanTreeHeader ui; + + private JTree getTree() { + return getUi().getTree(); + } + + @Override + public void beforeInit(BeanTreeHeader beanTreeHeader) { + this.ui = beanTreeHeader; + } + + @Override + public void afterInit(BeanTreeHeader beanTreeHeader) {} - public BeanTreeHeaderHandler(BeanTreeHeader ui) { - this.ui = ui; + public void collapseAll() { + // Let's deselect the nodes before collapsing them + deselectAll(); + + JTree tree = getTree(); + for (int i = 0; i < tree.getRowCount(); i++) { + tree.collapseRow(i); + } + } + + public void expandAll() { + JTree tree = getTree(); + for (int i = 0; i < tree.getRowCount(); i++) { + tree.expandRow(i); + } } - public void initUI() { + public void selectAll() { + // To be selected, nodes need to be expanded + expandAll(); + + JTree tree = getTree(); + TreeSelectionModel selectionModel = tree.getSelectionModel(); + for (int i = 0, l = tree.getRowCount(); i < l; i++) { + + TreePath path = tree.getPathForRow(i); + if (!selectionModel.isPathSelected(path)) { + tree.setSelectionPath(path); + } + } } + public void deselectAll() { + JTree tree = getTree(); + TreeSelectionModel selectionModel = tree.getSelectionModel(); + + for (int i = 0, l = tree.getRowCount(); i < l; i++) { + + TreePath path = tree.getPathForRow(i); + if (selectionModel.isPathSelected(path)) { + tree.setSelectionPath(path); + } + } + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm