Bläddra i källkod

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 år sedan
förälder
incheckning
f77c795b34

+ 3
- 1
src/com/dmdirc/addons/ui_swing/actions/CommandAction.java Visa fil

74
      */
74
      */
75
     @Override
75
     @Override
76
     public void actionPerformed(final ActionEvent e) {
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 Visa fil

1
 /*
1
 /*
2
- * 
2
+ *
3
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
3
  * Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
4
- * 
4
+ *
5
  * Permission is hereby granted, free of charge, to any person obtaining a copy
5
  * Permission is hereby granted, free of charge, to any person obtaining a copy
6
  * of this software and associated documentation files (the "Software"), to deal
6
  * of this software and associated documentation files (the "Software"), to deal
7
  * in the Software without restriction, including without limitation the rights
7
  * in the Software without restriction, including without limitation the rights
8
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
  * copies of the Software, and to permit persons to whom the Software is
9
  * copies of the Software, and to permit persons to whom the Software is
10
  * furnished to do so, subject to the following conditions:
10
  * furnished to do so, subject to the following conditions:
11
- * 
11
+ *
12
  * The above copyright notice and this permission notice shall be included in
12
  * The above copyright notice and this permission notice shall be included in
13
  * all copies or substantial portions of the Software.
13
  * all copies or substantial portions of the Software.
14
- * 
14
+ *
15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
165
                 getMousePosition() != null) {
165
                 getMousePosition() != null) {
166
             if (checkCursorInSelectedCell() || selectNickUnderCursor()) {
166
             if (checkCursorInSelectedCell() || selectNickUnderCursor()) {
167
                 if (e.isPopupTrigger()) {
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
                     frame.showPopupMenu(new ClickTypeValue(ClickType.NICKNAME,
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
             } else {
183
             } else {
174
                 nickList.clearSelection();
184
                 nickList.clearSelection();

+ 15
- 11
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java Visa fil

901
             final Point point) {
901
             final Point point) {
902
         final JPopupMenu popupMenu;
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
         switch (type.getType()) {
912
         switch (type.getType()) {
905
             case CHANNEL:
913
             case CHANNEL:
906
-                popupMenu = getPopupMenu(getChannelPopupType(),
907
-                        type.getValue());
914
+                popupMenu = getPopupMenu(getChannelPopupType(), arguments);
908
                 popupMenu.add(new ChannelCopyAction(type.getValue()));
915
                 popupMenu.add(new ChannelCopyAction(type.getValue()));
909
                 if (popupMenu.getComponentCount() > 1) {
916
                 if (popupMenu.getComponentCount() > 1) {
910
                     popupMenu.addSeparator();
917
                     popupMenu.addSeparator();
912
 
919
 
913
                 break;
920
                 break;
914
             case HYPERLINK:
921
             case HYPERLINK:
915
-                popupMenu = getPopupMenu(getHyperlinkPopupType(),
916
-                        type.getValue());
922
+                popupMenu = getPopupMenu(getHyperlinkPopupType(), arguments);
917
                 popupMenu.add(new HyperlinkCopyAction(type.getValue()));
923
                 popupMenu.add(new HyperlinkCopyAction(type.getValue()));
918
                 if (popupMenu.getComponentCount() > 1) {
924
                 if (popupMenu.getComponentCount() > 1) {
919
                     popupMenu.addSeparator();
925
                     popupMenu.addSeparator();
921
 
927
 
922
                 break;
928
                 break;
923
             case NICKNAME:
929
             case NICKNAME:
924
-                popupMenu = getPopupMenu(getNicknamePopupType(),
925
-                        type.getValue());
930
+                popupMenu = getPopupMenu(getNicknamePopupType(), arguments);
926
                 if (popupMenu.getComponentCount() > 0) {
931
                 if (popupMenu.getComponentCount() > 0) {
927
                     popupMenu.addSeparator();
932
                     popupMenu.addSeparator();
928
                 }
933
                 }
930
                 popupMenu.add(new NicknameCopyAction(type.getValue()));
935
                 popupMenu.add(new NicknameCopyAction(type.getValue()));
931
                 break;
936
                 break;
932
             default:
937
             default:
933
-                popupMenu = getPopupMenu(null, type.getValue());
938
+                popupMenu = getPopupMenu(null, arguments);
934
                 break;
939
                 break;
935
         }
940
         }
936
 
941
 
962
      *
967
      *
963
      * @return PopupMenu
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
         JPopupMenu popupMenu = new JPopupMenu();
972
         JPopupMenu popupMenu = new JPopupMenu();
969
 
973
 
970
         if (type != null) {
974
         if (type != null) {
987
      */
991
      */
988
     private JComponent populatePopupMenu(final JComponent menu,
992
     private JComponent populatePopupMenu(final JComponent menu,
989
             final PopupMenu popup,
993
             final PopupMenu popup,
990
-            final Object... arguments) {
994
+            final Object[][] arguments) {
991
         for (PopupMenuItem menuItem : popup.getItems()) {
995
         for (PopupMenuItem menuItem : popup.getItems()) {
992
             if (menuItem.isDivider()) {
996
             if (menuItem.isDivider()) {
993
                 menu.add(new JSeparator());
997
                 menu.add(new JSeparator());

+ 2
- 1
src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java Visa fil

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

+ 2
- 1
src/com/dmdirc/addons/ui_swing/framemanager/tree/Tree.java Visa fil

277
                 return;
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
             frame.addCustomPopupItems(popupMenu);
282
             frame.addCustomPopupItems(popupMenu);
282
             if (popupMenu.getComponentCount() > 0) {
283
             if (popupMenu.getComponentCount() > 0) {
283
                 popupMenu.addSeparator();
284
                 popupMenu.addSeparator();

Laddar…
Avbryt
Spara