jdoc
[nikiroo-utils.git] / ui / BreadCrumbsBar.java
index 0aea666aafb79da226422679ab508c05fc15d64a..da382f9ceaeb9ef8c5638dca51c09576db75a79d 100644 (file)
@@ -3,7 +3,6 @@ package be.nikiroo.utils.ui;
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
-import java.awt.FlowLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
@@ -13,7 +12,6 @@ import java.util.List;
 
 import javax.swing.AbstractAction;
 import javax.swing.BoxLayout;
-import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JToggleButton;
@@ -23,33 +21,35 @@ import javax.swing.event.PopupMenuListener;
 
 public class BreadCrumbsBar<T> extends ListenerPanel {
        private class BreadCrumb extends JPanel {
-               private JButton button;
+               private JToggleButton button;
                private JToggleButton down;
 
                public BreadCrumb(final DataNode<T> node) {
                        this.setLayout(new BorderLayout());
 
-                       button = new JButton(node.toString());
                        if (!node.isRoot()) {
-                               // TODO: allow clicking on root? option?
+                               button = new JToggleButton(node.toString());
                                button.addActionListener(new ActionListener() {
                                        @Override
                                        public void actionPerformed(ActionEvent e) {
-                                               setSelectedNode(node);
+                                               button.setSelected(false);
+                                               if (!node.isRoot()) {
+                                                       // TODO: allow clicking on root? option?
+                                                       setSelectedNode(node);
+                                               }
                                        }
                                });
+                               
+                               this.add(button, BorderLayout.CENTER);
                        }
 
-                       this.add(button, BorderLayout.CENTER);
-
                        if (!node.getChildren().isEmpty()) {
-                               // TODO (see things with icons included in viewer)
+                               // TODO allow an image or ">", viewer
                                down = new JToggleButton(">");
                                final JPopupMenu popup = new JPopupMenu();
 
                                for (final DataNode<T> child : node.getChildren()) {
                                        popup.add(new AbstractAction(child.toString()) {
-
                                                private static final long serialVersionUID = 1L;
 
                                                @Override
@@ -60,7 +60,6 @@ public class BreadCrumbsBar<T> extends ListenerPanel {
                                }
 
                                down.addActionListener(new ActionListener() {
-
                                        @Override
                                        public void actionPerformed(ActionEvent ev) {
                                                if (down.isSelected()) {
@@ -152,7 +151,7 @@ public class BreadCrumbsBar<T> extends ListenerPanel {
                                if (vertical) {
                                        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
                                } else {
-                                       this.setLayout(new FlowLayout(FlowLayout.LEADING));
+                                       this.setLayout(new WrapLayout(WrapLayout.LEADING));
                                }
 
                                for (BreadCrumb crumb : crumbs) {