Ticket #1650: SelectUser.patch.txt

File SelectUser.patch.txt, 2.2 KB (added by jpstotz, 16 years ago)

Select all nodes and ways of one user by double click in the user list

Line 
1### Eclipse Workspace Patch 1.0
2#P josm
3Index: src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
4===================================================================
5--- src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java (revision 1030)
6+++ src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java (working copy)
7@@ -5,10 +5,13 @@
8
9 import java.awt.BorderLayout;
10 import java.awt.event.KeyEvent;
11+import java.awt.event.MouseEvent;
12+import java.awt.event.MouseListener;
13 import java.util.Arrays;
14 import java.util.Collection;
15 import java.util.Comparator;
16 import java.util.HashMap;
17+import java.util.LinkedList;
18
19 import javax.swing.JScrollPane;
20 import javax.swing.JTable;
21@@ -28,7 +31,7 @@
22 *
23 * @author Frederik Ramm <frederik@remote.org>
24 */
25-public class UserListDialog extends ToggleDialog implements SelectionChangedListener {
26+public class UserListDialog extends ToggleDialog implements SelectionChangedListener, MouseListener{
27
28 /**
29 * The display list.
30@@ -54,7 +57,7 @@
31 userTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
32 add(new JScrollPane(userTable), BorderLayout.CENTER);
33 selectionChanged(Main.ds.getSelected());
34-
35+ userTable.addMouseListener(this);
36 DataSet.selListeners.add(this);
37 }
38
39@@ -107,4 +110,32 @@
40 }
41 }
42
43+ public void mouseClicked(MouseEvent e) {
44+ if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount()==2) {
45+ int index = userTable.getSelectedRow();
46+ String userName = (String) data.getValueAt(index, 0);
47+ if (userName==null)
48+ return;
49+ Collection<OsmPrimitive> selected = Main.ds.getSelected();
50+ Collection<OsmPrimitive> byUser = new LinkedList<OsmPrimitive>();
51+ for (OsmPrimitive p : selected) {
52+ if (p.user!= null && userName.equals(p.user.name))
53+ byUser.add(p);
54+ }
55+ Main.ds.setSelected(byUser);
56+ }
57+ }
58+
59+ public void mouseEntered(MouseEvent e) {
60+ }
61+
62+ public void mouseExited(MouseEvent e) {
63+ }
64+
65+ public void mousePressed(MouseEvent e) {
66+ }
67+
68+ public void mouseReleased(MouseEvent e) {
69+ }
70+
71 }