Changeset 1792 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-07-15T17:47:09+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r1790 r1792 2 2 package org.openstreetmap.josm.gui.dialogs.relation; 3 3 4 import java.awt.Rectangle; 4 5 import java.awt.event.ActionEvent; 5 6 import java.awt.event.KeyEvent; … … 12 13 import javax.swing.table.TableColumnModel; 13 14 14 public class MemberTable extends JTable {15 public class MemberTable extends JTable implements IMemberModelListener { 15 16 16 17 /** … … 22 23 public MemberTable(MemberTableModel model) { 23 24 super(model, new MemberTableColumnModel(), model.getSelectionModel()); 25 model.addMemberModelListener(this); 24 26 init(); 25 27 } … … 65 67 66 68 } 69 } 70 71 public void makeMemberVisible(int index) { 72 scrollRectToVisible( 73 getCellRect(index, 0, true) 74 ); 67 75 } 68 76 … … 126 134 } 127 135 } 136 137 128 138 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r1790 r1792 7 7 import java.util.Iterator; 8 8 import java.util.List; 9 import java.util.concurrent.CopyOnWriteArrayList; 9 10 10 11 import javax.swing.DefaultListSelectionModel; … … 23 24 private ArrayList<String> memberLinkingInfo; 24 25 private DefaultListSelectionModel listSelectionModel; 26 private CopyOnWriteArrayList<IMemberModelListener> listeners; 25 27 26 28 /** … … 30 32 members = new ArrayList<RelationMember>(); 31 33 memberLinkingInfo = new ArrayList<String>(); 34 listeners = new CopyOnWriteArrayList<IMemberModelListener>(); 35 } 36 37 public void addMemberModelListener(IMemberModelListener listener) { 38 synchronized(listeners) { 39 if (listener != null && ! listeners.contains(listener)) { 40 listeners.add(listener); 41 } 42 } 43 } 44 45 public void removeMemberModelListener(IMemberModelListener listener) { 46 synchronized(listeners) { 47 if (listener != null && listeners.contains(listener)) { 48 listeners.remove(listener); 49 } 50 } 51 } 52 53 protected void fireMakeMemberVisible(int index) { 54 synchronized(listeners) { 55 for (IMemberModelListener listener: listeners) { 56 listener.makeMemberVisible(index); 57 } 58 } 32 59 } 33 60 … … 91 118 listSelectionModel.addSelectionInterval(row, row); 92 119 } 120 fireMakeMemberVisible(selectedRows[0] -1); 93 121 } 94 122 … … 110 138 listSelectionModel.addSelectionInterval(row, row); 111 139 } 140 fireMakeMemberVisible(selectedRows[0] + 1); 112 141 } 113 142 … … 185 214 } 186 215 if (min < Integer.MAX_VALUE) { 187 //FIXME: scroll to min216 fireMakeMemberVisible(min); 188 217 } 189 218 } … … 233 262 getSelectionModel().addSelectionInterval(i,i); 234 263 } 264 fireMakeMemberVisible(0); 235 265 } 236 266 … … 247 277 getSelectionModel().addSelectionInterval(members.size()-1-i,members.size()-1-i); 248 278 } 279 fireMakeMemberVisible(members.size() -1); 249 280 } 250 281 … … 261 292 getSelectionModel().addSelectionInterval(idx+i,idx+i); 262 293 } 294 fireMakeMemberVisible(idx); 263 295 } 264 296 … … 276 308 getSelectionModel().addSelectionInterval(idx+1 + i,idx+1 +i); 277 309 } 310 fireMakeMemberVisible(idx+1); 278 311 } 279 312 }
Note:
See TracChangeset
for help on using the changeset viewer.