- Timestamp:
- 2011-01-07T00:54:21+01:00 (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/User.java
r3505 r3776 7 7 import java.util.List; 8 8 import java.util.concurrent.atomic.AtomicLong; 9 import org.openstreetmap.josm.io.MirroredInputStream; 10 import java.io.InputStreamReader; 11 import java.io.BufferedReader; 9 12 10 13 /** … … 25 28 */ 26 29 private static HashMap<Long,User> userMap = new HashMap<Long,User>(); 30 private static HashSet<Long> relicensingUsers = null; 27 31 28 32 private static long getNextLocalUid() { … … 102 106 } 103 107 108 public static void loadRelicensingInformation() { 109 relicensingUsers = new HashSet<Long>(); 110 try { 111 MirroredInputStream stream = new MirroredInputStream("http://planet.openstreetmap.org/users_agreed/users_agreed.txt"); 112 InputStreamReader r; 113 r = new InputStreamReader(stream); 114 BufferedReader reader = new BufferedReader(r); 115 String line; 116 while ((line = reader.readLine()) != null) { 117 if (line.startsWith("#")) continue; 118 try { 119 relicensingUsers.add(new Long(Long.parseLong(line.trim()))); 120 } catch (java.lang.NumberFormatException ex) { 121 } 122 } 123 stream.close(); 124 } catch (java.io.IOException ex) { 125 } 126 } 127 104 128 /** the user name */ 105 129 private final HashSet<String> names = new HashSet<String>(); 106 130 /** the user id */ 107 131 private final long uid; 132 133 public static final int STATUS_UNKNOWN = 0; 134 public static final int STATUS_AGREED = 1; 135 public static final int STATUS_NOT_AGREED = 2; 136 public static final int STATUS_AUTO_AGREED = 3; 137 138 /** 139 */ 140 public int getRelicensingStatus() { 141 if (uid >= 286582) return STATUS_AUTO_AGREED; 142 if (relicensingUsers == null) return STATUS_UNKNOWN; 143 return (relicensingUsers.contains(new Long(uid)) ? STATUS_AGREED : STATUS_NOT_AGREED); 144 } 108 145 109 146 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r3443 r3776 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.awt.Component; 7 8 import java.awt.BorderLayout; 8 9 import java.awt.event.ActionEvent; … … 29 30 import javax.swing.JScrollPane; 30 31 import javax.swing.JTable; 32 import javax.swing.JLabel; 31 33 import javax.swing.ListSelectionModel; 34 import javax.swing.table.DefaultTableCellRenderer; 35 import javax.swing.table.TableColumnModel; 32 36 import javax.swing.event.ListSelectionEvent; 33 37 import javax.swing.event.ListSelectionListener; … … 46 50 import org.openstreetmap.josm.tools.ImageProvider; 47 51 import org.openstreetmap.josm.tools.Shortcut; 52 import org.openstreetmap.josm.tools.ImageProvider; 53 import javax.swing.ImageIcon; 48 54 49 55 /** … … 61 67 private SelectUsersPrimitivesAction selectionUsersPrimitivesAction; 62 68 private ShowUserInfoAction showUserInfoAction; 69 private LoadRelicensingInformationAction loadRelicensingInformationAction; 63 70 64 71 public UserListDialog() { … … 95 102 userTable.getSelectionModel().addListSelectionListener(showUserInfoAction); 96 103 pnl.add(new SideButton(showUserInfoAction)); 104 105 // -- load relicensing info action 106 loadRelicensingInformationAction = new LoadRelicensingInformationAction(); 107 pnl.add(new SideButton(loadRelicensingInformationAction)); 97 108 return pnl; 98 109 } … … 104 115 userTable = new JTable(model); 105 116 userTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 117 TableColumnModel columnModel = userTable.getColumnModel(); 118 columnModel.getColumn(3).setPreferredWidth(20); 119 columnModel.getColumn(3).setCellRenderer(new DefaultTableCellRenderer() { 120 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { 121 final JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 122 label.setIcon((ImageIcon)value); 123 label.setText(""); 124 return label; 125 }; 126 }); 106 127 pnl.add(new JScrollPane(userTable), BorderLayout.CENTER); 107 128 … … 182 203 } 183 204 184 /* *205 /* 185 206 * Action for launching the info page of a user 186 207 */ … … 244 265 } 245 266 267 /* 268 */ 269 class LoadRelicensingInformationAction extends AbstractAction { 270 271 public LoadRelicensingInformationAction() { 272 super(); 273 putValue(NAME, tr("Load CT")); 274 putValue(SHORT_DESCRIPTION, tr("Loads information about relicensing status from the server. Users having agreed to the new contributor terms will show a green check mark.")); 275 putValue(SMALL_ICON, ImageProvider.get("about")); 276 } 277 278 @Override 279 public void actionPerformed(ActionEvent e) { 280 User.loadRelicensingInformation(); 281 Layer layer = Main.main.getActiveLayer(); 282 if (layer instanceof OsmDataLayer) { 283 refresh(((OsmDataLayer)layer).data.getSelected()); 284 } 285 setEnabled(false); 286 } 287 } 288 246 289 class DoubleClickAdapter extends MouseAdapter { 247 290 @Override … … 280 323 return user.getName(); 281 324 } 325 326 public int getRelicensingStatus() { 327 if (user == null) 328 return User.STATUS_UNKNOWN; 329 return user.getRelicensingStatus(); 330 } 282 331 } 283 332 … … 288 337 static class UserTableModel extends DefaultTableModel { 289 338 private ArrayList<UserInfo> data; 339 private ImageIcon greenCheckmark; 290 340 291 341 public UserTableModel() { 292 setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%" });342 setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%", tr("CT")}); 293 343 data = new ArrayList<UserInfo>(); 344 greenCheckmark = ImageProvider.get("misc", "green_check.png"); 294 345 } 295 346 … … 332 383 case 1: /* count */ return info.count; 333 384 case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent); 385 case 3: /* relicensing status */ 386 if (info.getRelicensingStatus() == User.STATUS_AGREED) return greenCheckmark; 387 if (info.getRelicensingStatus() == User.STATUS_AUTO_AGREED) return greenCheckmark; 388 return null; 334 389 } 335 390 return null;
Note:
See TracChangeset
for help on using the changeset viewer.