Changeset 5495 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2012-09-02T14:20:28+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/User.java
r4602 r5495 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedReader;7 import java.io.InputStreamReader;8 import java.io.IOException;9 10 6 import java.util.ArrayList; 11 import java.util.concurrent.atomic.AtomicLong;12 7 import java.util.HashMap; 13 8 import java.util.HashSet; 14 9 import java.util.List; 15 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.io.MirroredInputStream; 10 import java.util.concurrent.atomic.AtomicLong; 11 18 12 import org.openstreetmap.josm.tools.Utils; 19 13 … … 35 29 */ 36 30 private static HashMap<Long,User> userMap = new HashMap<Long,User>(); 37 private static HashSet<Long> relicensingUsers = null;38 private static HashSet<Long> nonRelicensingUsers = null;39 31 private final static User anonymous = createLocalUser(tr("<anonymous>")); 40 32 … … 119 111 } 120 112 121 public static void initRelicensingInformation() {122 if (relicensingUsers == null) {123 loadRelicensingInformation(false);124 }125 }126 127 public static void loadRelicensingInformation(boolean clean) {128 relicensingUsers = new HashSet<Long>();129 nonRelicensingUsers = new HashSet<Long>();130 try {131 MirroredInputStream stream = new MirroredInputStream(132 Main.pref.get("url.licensechange",133 "http://planet.openstreetmap.org/users_agreed/users_agreed.txt"),134 clean ? 1 : 7200);135 try {136 InputStreamReader r;137 r = new InputStreamReader(stream);138 BufferedReader reader = new BufferedReader(r);139 String line;140 while ((line = reader.readLine()) != null) {141 if (line.startsWith("#")) continue;142 try {143 Long id = new Long(Long.parseLong(line.trim()));144 relicensingUsers.add(id);145 } catch (java.lang.NumberFormatException ex) {146 }147 }148 }149 finally {150 stream.close();151 }152 } catch (IOException ex) {153 }154 155 try {156 MirroredInputStream stream = new MirroredInputStream(157 Main.pref.get("url.licensechange_reject",158 "http://planet.openstreetmap.org/users_agreed/users_disagreed.txt"),159 clean ? 1 : 7200);160 try {161 InputStreamReader r;162 r = new InputStreamReader(stream);163 BufferedReader reader = new BufferedReader(r);164 String line;165 while ((line = reader.readLine()) != null) {166 if (line.startsWith("#")) continue;167 try {168 Long id = new Long(Long.parseLong(line.trim()));169 nonRelicensingUsers.add(id);170 } catch (java.lang.NumberFormatException ex) {171 }172 }173 }174 finally {175 stream.close();176 }177 } catch (IOException ex) {178 }179 }180 181 113 /** the user name */ 182 114 private final HashSet<String> names = new HashSet<String>(); 183 115 /** the user id */ 184 116 private final long uid; 185 private int relicensingStatus = STATUS_UNKNOWN;186 187 public static final int STATUS_UNKNOWN = -1;188 public static final int STATUS_UNDECIDED = 0;189 public static final int STATUS_AGREED = 1;190 public static final int STATUS_NOT_AGREED = 2;191 public static final int STATUS_AUTO_AGREED = 3;192 public static final int STATUS_ANONYMOUS = 4;193 194 /**195 * Finds out this user's relicensing status and saves it for quicker196 * access.197 */198 public int getRelicensingStatus() {199 if (relicensingStatus != STATUS_UNKNOWN) return relicensingStatus;200 if (uid >= 286582) return (relicensingStatus = STATUS_AUTO_AGREED);201 if (relicensingUsers == null) return STATUS_UNKNOWN;202 Long id = new Long(uid);203 if (relicensingUsers.contains(id)) return (relicensingStatus = STATUS_AGREED);204 if (nonRelicensingUsers == null) return STATUS_UNKNOWN;205 if (nonRelicensingUsers.contains(id)) return (relicensingStatus = STATUS_NOT_AGREED);206 return STATUS_UNDECIDED;207 }208 209 /**210 * Sets this user's relicensing status. This can be used if relicensing211 * information is available from another source so that directly looking212 * at the users_agreed/users_not_agreed files it not required.213 */214 public void setRelicensingStatus(int status) {215 relicensingStatus = status;216 }217 117 218 118 /** -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r5360 r5495 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.awt.Component;8 7 import java.awt.event.ActionEvent; 9 8 import java.awt.event.KeyEvent; … … 26 25 27 26 import javax.swing.AbstractAction; 28 import javax.swing.JLabel;29 27 import javax.swing.JOptionPane; 30 28 import javax.swing.JTable; … … 32 30 import javax.swing.event.ListSelectionEvent; 33 31 import javax.swing.event.ListSelectionListener; 34 import javax.swing.table.DefaultTableCellRenderer;35 32 import javax.swing.table.DefaultTableModel; 36 import javax.swing.table.TableColumnModel;37 33 38 34 import org.openstreetmap.josm.Main; … … 46 42 import org.openstreetmap.josm.gui.layer.Layer; 47 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 48 import org.openstreetmap.josm.gui.progress.ContributorTermsUpdateRunnable;49 44 import org.openstreetmap.josm.tools.ImageProvider; 50 45 import org.openstreetmap.josm.tools.Shortcut; … … 64 59 private SelectUsersPrimitivesAction selectionUsersPrimitivesAction; 65 60 private ShowUserInfoAction showUserInfoAction; 66 private LoadRelicensingInformationAction loadRelicensingInformationAction;67 61 68 62 public UserListDialog() { … … 90 84 userTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); 91 85 userTable.addMouseListener(new DoubleClickAdapter()); 92 TableColumnModel columnModel = userTable.getColumnModel();93 columnModel.getColumn(3).setPreferredWidth(20);94 columnModel.getColumn(3).setCellRenderer(new DefaultTableCellRenderer() {95 @Override96 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {97 // see http://download.oracle.com/javase/6/docs/api/javax/swing/table/DefaultTableCellRenderer.html#override98 // for why we don't use the label directly99 final JLabel renderLabel = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);100 JLabel sourceLabel = (JLabel) value;101 renderLabel.setIcon(sourceLabel.getIcon());102 renderLabel.setText("");103 renderLabel.setToolTipText(sourceLabel.getToolTipText());104 return renderLabel;105 }106 });107 86 108 87 // -- select users primitives action … … 116 95 userTable.getSelectionModel().addListSelectionListener(showUserInfoAction); 117 96 118 // -- load relicensing info action119 loadRelicensingInformationAction = new LoadRelicensingInformationAction();120 121 97 createLayout(userTable, true, Arrays.asList(new SideButton[] { 122 98 new SideButton(selectionUsersPrimitivesAction), 123 new SideButton(showUserInfoAction), 124 new SideButton(loadRelicensingInformationAction) 99 new SideButton(showUserInfoAction) 125 100 })); 126 101 } … … 162 137 public void showDialog() { 163 138 super.showDialog(); 164 Main.worker.submit(new ContributorTermsUpdateRunnable());165 139 Layer layer = Main.main.getActiveLayer(); 166 140 if (layer instanceof OsmDataLayer) { … … 259 233 } 260 234 261 /*262 */263 class LoadRelicensingInformationAction extends AbstractAction {264 265 public LoadRelicensingInformationAction() {266 super();267 putValue(NAME, tr("Load CT"));268 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."));269 putValue(SMALL_ICON, ImageProvider.get("about"));270 }271 272 @Override273 public void actionPerformed(ActionEvent e) {274 Main.worker.submit(new ContributorTermsUpdateRunnable());275 Layer layer = Main.main.getActiveLayer();276 if (layer instanceof OsmDataLayer) {277 refresh(((OsmDataLayer)layer).data.getAllSelected());278 }279 setEnabled(false);280 }281 }282 283 235 class DoubleClickAdapter extends MouseAdapter { 284 236 @Override … … 317 269 return user.getName(); 318 270 } 319 320 public int getRelicensingStatus() {321 if (user == null)322 return User.STATUS_UNKNOWN;323 return user.getRelicensingStatus();324 }325 271 } 326 272 … … 333 279 334 280 public UserTableModel() { 335 setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%" , tr("CT")});281 setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%"}); 336 282 data = new ArrayList<UserInfo>(); 337 283 } … … 375 321 case 1: /* count */ return info.count; 376 322 case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent); 377 case 3: /* relicensing status */ return getRelicensingStatusIcon(info.getRelicensingStatus());378 323 } 379 324 return null; … … 412 357 } 413 358 } 414 415 private static JLabel greenCheckmark;416 private static JLabel greyCheckmark;417 private static JLabel redX;418 private static JLabel empty;419 420 public static JLabel getRelicensingStatusIcon(int status) {421 switch(status) {422 case User.STATUS_AGREED:423 if (greenCheckmark == null) {424 greenCheckmark = new JLabel(ImageProvider.get("misc", "green_check.png"));425 greenCheckmark.setToolTipText(tr("Accepted"));426 }427 return greenCheckmark;428 case User.STATUS_AUTO_AGREED:429 if (greyCheckmark == null) {430 greyCheckmark = new JLabel(ImageProvider.get("misc", "grey_check.png"));431 greyCheckmark.setToolTipText(tr("Auto-accepted"));432 }433 return greyCheckmark;434 case User.STATUS_NOT_AGREED:435 if (redX == null) {436 redX = new JLabel(ImageProvider.get("misc", "red_x.png"));437 redX.setToolTipText(tr("Declined"));438 }439 return redX;440 default:441 if (empty == null) {442 empty = new JLabel("");443 empty.setToolTipText(tr("Undecided"));444 }445 }446 return empty; // Undecided or unknown?447 }448 359 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java
r5266 r5495 50 50 import org.openstreetmap.josm.gui.history.HistoryLoadTask; 51 51 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 52 import org.openstreetmap.josm.gui.progress.ContributorTermsUpdateRunnable;53 52 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 54 53 import org.openstreetmap.josm.tools.ImageProvider; … … 264 263 265 264 public void showHistory(final Collection<HistoryOsmPrimitive> primitives) { 266 Main.worker.submit(new ContributorTermsUpdateRunnable());267 265 268 266 List<HistoryOsmPrimitive> toLoad = filterPrimitivesWithUnloadedHistory(primitives); -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
r5460 r5495 20 20 import org.openstreetmap.josm.gui.MapView; 21 21 import org.openstreetmap.josm.gui.layer.Layer; 22 import org.openstreetmap.josm.gui.progress.ContributorTermsUpdateRunnable;23 22 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 24 23 import org.openstreetmap.josm.tools.Predicate; … … 146 145 return; 147 146 } 148 149 Main.worker.submit(new ContributorTermsUpdateRunnable());150 147 151 148 Collection<OsmPrimitive> toLoad = Utils.filter(primitives, unloadedHistoryPredicate); -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r5440 r5495 10 10 import java.util.Observable; 11 11 12 import javax.swing.JTable; 12 13 import javax.swing.table.AbstractTableModel; 14 import javax.swing.table.TableModel; 13 15 14 16 import org.openstreetmap.josm.Main; … … 40 42 import org.openstreetmap.josm.gui.MapView; 41 43 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 42 import org.openstreetmap.josm.gui.dialogs.UserListDialog;43 44 import org.openstreetmap.josm.gui.layer.Layer; 44 45 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 428 429 return isCurrentPointInTime(row); 429 430 case 3: { 430 User user = getPrimitive(row).getUser();431 int status;432 if (user == null) {433 status = User.STATUS_UNKNOWN;434 } else {435 status = user.getRelicensingStatus();436 }437 return UserListDialog.getRelicensingStatusIcon(status);438 }439 case 4: {440 431 HistoryOsmPrimitive p = getPrimitive(row); 441 432 if (p != null && p.getTimestamp() != null) … … 443 434 return null; 444 435 } 445 case 5: {436 case 4: { 446 437 HistoryOsmPrimitive p = getPrimitive(row); 447 438 if (p != null) { -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r5264 r5495 58 58 adjustColumnWidth(VersionTable.this, 3, 0); 59 59 adjustColumnWidth(VersionTable.this, 4, 0); 60 adjustColumnWidth(VersionTable.this, 5, 0);61 60 } 62 61 }); -
trunk/src/org/openstreetmap/josm/gui/history/VersionTableColumnModel.java
r5440 r5495 39 39 col.setResizable(false); 40 40 addColumn(col); 41 // column 3 - CT state41 // column 3 - Date 42 42 col = new TableColumn(3); 43 /* translation note: short for "Contributor Terms" */44 col.setHeaderValue(tr("CT"));45 col.setCellRenderer(new VersionTable.LabelRenderer());46 col.setPreferredWidth(22);47 col.setResizable(false);48 addColumn(col);49 // column 4 - Date50 col = new TableColumn(4);51 43 col.setHeaderValue(tr("Date")); 52 44 col.setResizable(false); 53 45 addColumn(col); 54 // column 5- User55 col = new TableColumn( 5);46 // column 4 - User 47 col = new TableColumn(4); 56 48 col.setHeaderValue(tr("User")); 57 49 col.setResizable(false);
Note:
See TracChangeset
for help on using the changeset viewer.