Browse Source

UI support for multiple selection in popups

Fixes CLIENT-87

Change-Id: I7684eb14f330ee46ed57fd764f5794b1c948672b
Depends-On: Id9d28d2db1f9f972b841f372f322a0968132600d
Reviewed-on: http://gerrit.dmdirc.com/1608
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.6.5
Chris Smith 13 years ago
parent
commit
f77c795b34

+ 3
- 1
src/com/dmdirc/addons/ui_swing/actions/CommandAction.java View File

@@ -74,7 +74,9 @@ public class CommandAction extends AbstractAction {
74 74
      */
75 75
     @Override
76 76
     public void actionPerformed(final ActionEvent e) {
77
-        parser.parseCommand(window.getContainer(), window, command);
77
+        for (String line : command.split("\n")) {
78
+            parser.parseCommand(window.getContainer(), window, line);
79
+        }
78 80
     }
79 81
     
80 82
 }

+ 17
- 7
src/com/dmdirc/addons/ui_swing/components/NickList.java View File

@@ -1,17 +1,17 @@
1 1
 /*
2
- * 
2
+ *
3 3
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- * 
4
+ *
5 5
  * Permission is hereby granted, free of charge, to any person obtaining a copy
6 6
  * of this software and associated documentation files (the "Software"), to deal
7 7
  * in the Software without restriction, including without limitation the rights
8 8
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 9
  * copies of the Software, and to permit persons to whom the Software is
10 10
  * furnished to do so, subject to the following conditions:
11
- * 
11
+ *
12 12
  * The above copyright notice and this permission notice shall be included in
13 13
  * all copies or substantial portions of the Software.
14
- * 
14
+ *
15 15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 16
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 17
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -165,10 +165,20 @@ public class NickList extends JScrollPane implements ConfigChangeListener,
165 165
                 getMousePosition() != null) {
166 166
             if (checkCursorInSelectedCell() || selectNickUnderCursor()) {
167 167
                 if (e.isPopupTrigger()) {
168
+                    final Object[] values = nickList.getSelectedValues();
169
+                    final StringBuilder builder = new StringBuilder();
170
+
171
+                    for (Object value : values) {
172
+                        if (builder.length() > 0) {
173
+                            builder.append("\n");
174
+                        }
175
+
176
+                        builder.append(((ChannelClientInfo) value).getClient().getNickname());
177
+                    }
178
+
168 179
                     frame.showPopupMenu(new ClickTypeValue(ClickType.NICKNAME,
169
-                            ((ChannelClientInfo) nickList.getSelectedValue())
170
-                            .getClient().getNickname()), new Point(e
171
-                            .getXOnScreen(), e.getYOnScreen()));
180
+                            builder.toString()), new Point(e.getXOnScreen(),
181
+                            e.getYOnScreen()));
172 182
                 }
173 183
             } else {
174 184
                 nickList.clearSelection();

+ 15
- 11
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java View File

@@ -901,10 +901,17 @@ public abstract class TextFrame extends JInternalFrame implements Window,
901 901
             final Point point) {
902 902
         final JPopupMenu popupMenu;
903 903
 
904
+        final String[] parts = type.getValue().split("\n");
905
+        final Object[][] arguments = new Object[parts.length][1];
906
+
907
+        int i = 0;
908
+        for (String part : parts) {
909
+            arguments[i++][0] = part;
910
+        }
911
+
904 912
         switch (type.getType()) {
905 913
             case CHANNEL:
906
-                popupMenu = getPopupMenu(getChannelPopupType(),
907
-                        type.getValue());
914
+                popupMenu = getPopupMenu(getChannelPopupType(), arguments);
908 915
                 popupMenu.add(new ChannelCopyAction(type.getValue()));
909 916
                 if (popupMenu.getComponentCount() > 1) {
910 917
                     popupMenu.addSeparator();
@@ -912,8 +919,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
912 919
 
913 920
                 break;
914 921
             case HYPERLINK:
915
-                popupMenu = getPopupMenu(getHyperlinkPopupType(),
916
-                        type.getValue());
922
+                popupMenu = getPopupMenu(getHyperlinkPopupType(), arguments);
917 923
                 popupMenu.add(new HyperlinkCopyAction(type.getValue()));
918 924
                 if (popupMenu.getComponentCount() > 1) {
919 925
                     popupMenu.addSeparator();
@@ -921,8 +927,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
921 927
 
922 928
                 break;
923 929
             case NICKNAME:
924
-                popupMenu = getPopupMenu(getNicknamePopupType(),
925
-                        type.getValue());
930
+                popupMenu = getPopupMenu(getNicknamePopupType(), arguments);
926 931
                 if (popupMenu.getComponentCount() > 0) {
927 932
                     popupMenu.addSeparator();
928 933
                 }
@@ -930,7 +935,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
930 935
                 popupMenu.add(new NicknameCopyAction(type.getValue()));
931 936
                 break;
932 937
             default:
933
-                popupMenu = getPopupMenu(null, type.getValue());
938
+                popupMenu = getPopupMenu(null, arguments);
934 939
                 break;
935 940
         }
936 941
 
@@ -962,9 +967,8 @@ public abstract class TextFrame extends JInternalFrame implements Window,
962 967
      *
963 968
      * @return PopupMenu
964 969
      */
965
-    public JPopupMenu getPopupMenu(
966
-            final PopupType type,
967
-            final Object... arguments) {
970
+    public JPopupMenu getPopupMenu(final PopupType type,
971
+            final Object[][] arguments) {
968 972
         JPopupMenu popupMenu = new JPopupMenu();
969 973
 
970 974
         if (type != null) {
@@ -987,7 +991,7 @@ public abstract class TextFrame extends JInternalFrame implements Window,
987 991
      */
988 992
     private JComponent populatePopupMenu(final JComponent menu,
989 993
             final PopupMenu popup,
990
-            final Object... arguments) {
994
+            final Object[][] arguments) {
991 995
         for (PopupMenuItem menuItem : popup.getItems()) {
992 996
             if (menuItem.isDivider()) {
993 997
                 menu.add(new JSeparator());

+ 2
- 1
src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java View File

@@ -528,7 +528,8 @@ public final class ButtonBar implements FrameManager, ActionListener,
528 528
             if (frame == null) {
529 529
                 return;
530 530
             }
531
-            final JPopupMenu popupMenu = frame.getPopupMenu(null, "");
531
+            final JPopupMenu popupMenu = frame.getPopupMenu(null,
532
+                    new Object[][] { new Object[] { "" } });
532 533
             frame.addCustomPopupItems(popupMenu);
533 534
             popupMenu.add(new JMenuItem(new CloseFrameContainerAction(frame.
534 535
                         getContainer())));

+ 2
- 1
src/com/dmdirc/addons/ui_swing/framemanager/tree/Tree.java View File

@@ -277,7 +277,8 @@ public class Tree extends JTree implements MouseMotionListener,
277 277
                 return;
278 278
             }
279 279
 
280
-            final JPopupMenu popupMenu = frame.getPopupMenu(null, "");
280
+            final JPopupMenu popupMenu = frame.getPopupMenu(null,
281
+                    new Object[][] { new Object[] { "" } });
281 282
             frame.addCustomPopupItems(popupMenu);
282 283
             if (popupMenu.getComponentCount() > 0) {
283 284
                 popupMenu.addSeparator();

Loading…
Cancel
Save