Changeset 3776 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2011-01-07T00:54:21+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.
