Selaa lähdekoodia

Fixes issue 3723: about dialog licences tree needs to refuse deselection and only allow single row selection

Change-Id: I9996b3c6b65b85417e33744047ba881dbb16410c
Reviewed-on: http://gerrit.dmdirc.com/836
Reviewed-by: Chris Smith <chris@dmdirc.com>
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
tags/0.6.3
Gregory Holmes 14 vuotta sitten
vanhempi
commit
68a00c666c

+ 6
- 0
src/com/dmdirc/addons/ui_swing/dialogs/about/LicencesPanel.java Näytä tiedosto

@@ -41,6 +41,7 @@ import javax.swing.text.html.HTMLDocument;
41 41
 import javax.swing.text.html.HTMLEditorKit;
42 42
 import javax.swing.tree.DefaultMutableTreeNode;
43 43
 import javax.swing.tree.DefaultTreeModel;
44
+import javax.swing.tree.TreeSelectionModel;
44 45
 import net.miginfocom.layout.PlatformDefaults;
45 46
 
46 47
 import net.miginfocom.swing.MigLayout;
@@ -119,6 +120,8 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
119 120
         list.setCellRenderer(new LicenceRenderer());
120 121
         list.setRootVisible(false);
121 122
         list.setOpaque(false);
123
+        list.getSelectionModel().setSelectionMode(TreeSelectionModel.
124
+                SINGLE_TREE_SELECTION);
122 125
         new TreeScroller(list);
123 126
         new LicenceLoader(list, listModel).execute();
124 127
         licence = new JEditorPane();
@@ -134,6 +137,9 @@ public final class LicencesPanel extends JPanel implements TreeSelectionListener
134 137
     /** {@inheritDoc} */
135 138
     @Override
136 139
     public void valueChanged(final TreeSelectionEvent e) {
140
+        if (list.getSelectionCount() == 0) {
141
+            list.setSelectionPath(e.getOldLeadSelectionPath());
142
+        }
137 143
         list.scrollPathToVisible(e.getPath());
138 144
         final Object userObject = ((DefaultMutableTreeNode) e.getPath().
139 145
                 getLastPathComponent()).getUserObject();

Loading…
Peruuta
Tallenna