- Timestamp:
- 2018-05-22T02:42:11+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r13434 r13817 21 21 import java.util.Map; 22 22 import java.util.Set; 23 import java.util.stream.Collectors; 23 24 24 25 import javax.swing.AbstractAction; 26 import javax.swing.JPopupMenu; 25 27 import javax.swing.JTable; 26 28 import javax.swing.ListSelectionModel; … … 38 40 import org.openstreetmap.josm.gui.MainApplication; 39 41 import org.openstreetmap.josm.gui.SideButton; 42 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 40 43 import org.openstreetmap.josm.gui.layer.Layer; 41 44 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; … … 43 46 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 44 47 import org.openstreetmap.josm.gui.util.GuiHelper; 48 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 45 49 import org.openstreetmap.josm.tools.ImageProvider; 46 50 import org.openstreetmap.josm.tools.Logging; … … 52 56 * Displays a dialog with all users who have last edited something in the 53 57 * selection area, along with the number of objects. 54 * 58 * @since 237 55 59 */ 56 60 public class UserListDialog extends ToggleDialog implements DataSelectionListener, ActiveLayerChangeListener { … … 62 66 private UserTableModel model; 63 67 private SelectUsersPrimitivesAction selectionUsersPrimitivesAction; 68 private final JPopupMenu popupMenu = new JPopupMenu(); 64 69 65 70 /** … … 104 109 new SideButton(showUserInfoAction) 105 110 )); 111 112 // -- popup menu 113 popupMenu.add(new AbstractAction(tr("Copy")) { 114 @Override 115 public void actionPerformed(ActionEvent e) { 116 ClipboardUtils.copyString(getSelectedUsers().stream().map(User::getName).collect(Collectors.joining(", "))); 117 } 118 }); 119 userTable.addMouseListener(new PopupMenuLauncher(popupMenu)); 106 120 } 107 121 … … 144 158 super.showDialog(); 145 159 refreshForActiveLayer(MainApplication.getLayerManager().getActiveLayer()); 160 } 161 162 private List<User> getSelectedUsers() { 163 int[] rows = userTable.getSelectedRows(); 164 return rows.length == 0 ? Collections.emptyList() : model.getSelectedUsers(rows); 146 165 } 147 166 … … 195 214 @Override 196 215 public void actionPerformed(ActionEvent e) { 197 int[] rows = userTable.getSelectedRows(); 198 if (rows.length == 0) 199 return; 200 List<User> users = model.getSelectedUsers(rows); 216 List<User> users = getSelectedUsers(); 201 217 if (users.isEmpty()) 202 218 return;
Note:
See TracChangeset
for help on using the changeset viewer.