Changeset 9136 in josm
- Timestamp:
- 2015-12-17T00:12:03+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractInfoAction.java
r8510 r9136 23 23 import org.openstreetmap.josm.tools.Shortcut; 24 24 25 /** 26 * Abstract base class for info actions, opening an URL describing a particular object. 27 * @since 1697 28 */ 25 29 public abstract class AbstractInfoAction extends JosmAction { 26 30 31 /** 32 * Constructs a new {@code AbstractInfoAction}. 33 * @param installAdapters false, if you don't want to install layer changed and selection changed adapters 34 */ 27 35 public AbstractInfoAction(boolean installAdapters) { 28 36 super(installAdapters); 29 37 } 30 38 39 /** 40 * Constructs a new {@code AbstractInfoAction}. 41 * @param name the action's text as displayed on the menu (if it is added to a menu) 42 * @param iconName the filename of the icon to use 43 * @param tooltip a longer description of the action that will be displayed in the tooltip. Please note 44 * that html is not supported for menu actions on some platforms. 45 * @param shortcut a ready-created shortcut object or null if you don't want a shortcut. But you always 46 * do want a shortcut, remember you can always register it with group=none, so you 47 * won't be assigned a shortcut unless the user configures one. If you pass null here, 48 * the user CANNOT configure a shortcut for your action. 49 * @param register register this action for the toolbar preferences? 50 * @param toolbarId identifier for the toolbar preferences. The iconName is used, if this parameter is null 51 * @param installAdapters false, if you don't want to install layer changed and selection changed adapters 52 */ 31 53 public AbstractInfoAction(String name, String iconName, String tooltip, Shortcut shortcut, boolean register, 32 54 String toolbarId, boolean installAdapters) { … … 34 56 } 35 57 58 /** 59 * Asks user confirmation before launching a large number of browser windows. 60 * @param numBrowsers the number of browser windows to open 61 * @return {@code true} if the user confirms, {@code false} otherwise 62 */ 36 63 public static boolean confirmLaunchMultiple(int numBrowsers) { 37 64 String msg = /* for correct i18n of plural forms - see #9110 */ trn( -
trunk/src/org/openstreetmap/josm/actions/HistoryInfoWebAction.java
r8846 r9136 12 12 import org.openstreetmap.josm.tools.Shortcut; 13 13 14 /** 15 * Display history information about OSM ways, nodes, or relations in web browser. 16 * @since 4408 17 */ 14 18 public class HistoryInfoWebAction extends AbstractInfoAction { 15 19 -
trunk/src/org/openstreetmap/josm/actions/InfoWebAction.java
r8846 r9136 59 59 private void updateEnabledStateWithNotes() { 60 60 // Allows enabling if a note is selected, even if no OSM object is selected 61 if (!isEnabled() && Main.isDisplayingMapView()) { 62 if (Main.map.noteDialog.getSelectedNote() != null) { 63 setEnabled(true); 64 } 61 if (!isEnabled() && Main.isDisplayingMapView() && Main.map.noteDialog.getSelectedNote() != null) { 62 setEnabled(true); 65 63 } 66 64 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r9078 r9136 131 131 } 132 132 133 /** 134 * Refreshes user list from given collection of OSM primitives. 135 * @param fromPrimitives OSM primitives to fetch users from 136 */ 133 137 public void refresh(Collection<? extends OsmPrimitive> fromPrimitives) { 134 138 model.populate(fromPrimitives); … … 152 156 refresh(((OsmDataLayer) layer).data.getAllSelected()); 153 157 } 154 155 158 } 156 159 … … 169 172 public void select() { 170 173 int[] indexes = userTable.getSelectedRows(); 171 if (indexes == null || indexes.length == 0) return; 174 if (indexes == null || indexes.length == 0) 175 return; 172 176 model.selectPrimitivesOwnedBy(userTable.getSelectedRows()); 173 177 } … … 188 192 } 189 193 190 /* 191 * Action for launching the info page of a user 194 /** 195 * Action for launching the info page of a user. 192 196 */ 193 197 class ShowUserInfoAction extends AbstractInfoAction implements ListSelectionListener { … … 204 208 public void actionPerformed(ActionEvent e) { 205 209 int[] rows = userTable.getSelectedRows(); 206 if (rows == null || rows.length == 0) return; 210 if (rows == null || rows.length == 0) 211 return; 207 212 List<User> users = model.getSelectedUsers(rows); 208 if (users.isEmpty()) return; 213 if (users.isEmpty()) 214 return; 209 215 if (users.size() > 10) { 210 216 Main.warn(tr("Only launching info browsers for the first {0} of {1} selected users", 10, users.size())); … … 257 263 */ 258 264 private static class UserInfo implements Comparable<UserInfo> { 259 public User user;260 public int count;261 public double percent;265 public final User user; 266 public final int count; 267 public final double percent; 262 268 263 269 UserInfo(User user, int count, double percent) { … … 269 275 @Override 270 276 public int compareTo(UserInfo o) { 271 if (count < o.count) return 1; 272 if (count > o.count) return -1; 273 if (user == null || user.getName() == null) return 1; 274 if (o.user == null || o.user.getName() == null) return -1; 277 if (count < o.count) 278 return 1; 279 if (count > o.count) 280 return -1; 281 if (user == null || user.getName() == null) 282 return 1; 283 if (o.user == null || o.user.getName() == null) 284 return -1; 275 285 return user.getName().compareTo(o.user.getName()); 276 286 } … … 297 307 protected Map<User, Integer> computeStatistics(Collection<? extends OsmPrimitive> primitives) { 298 308 Map<User, Integer> ret = new HashMap<>(); 299 if (primitives == null || primitives.isEmpty()) return ret; 309 if (primitives == null || primitives.isEmpty()) 310 return ret; 300 311 for (OsmPrimitive primitive: primitives) { 301 312 if (ret.containsKey(primitive.getUser())) { … … 327 338 @Override 328 339 public int getRowCount() { 329 if (data == null) return 0; 340 if (data == null) 341 return 0; 330 342 return data.size(); 331 343 } … … 338 350 case 1: /* count */ return info.count; 339 351 case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent); 340 }341 return null;352 default: return null; 353 } 342 354 } 343 355 … … 364 376 public List<User> getSelectedUsers(int[] rows) { 365 377 List<User> ret = new LinkedList<>(); 366 if (rows == null || rows.length == 0) return ret; 378 if (rows == null || rows.length == 0) 379 return ret; 367 380 for (int row: rows) { 368 381 if (data.get(row).user == null) { -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r9078 r9136 47 47 private VersionTablePopupMenu popupMenu; 48 48 private final transient HistoryBrowserModel model; 49 50 /** 51 * Constructs a new {@code VersionTable}. 52 * @param model model used by the history browser 53 */ 54 public VersionTable(HistoryBrowserModel model) { 55 super(model.getVersionTableModel(), new VersionTableColumnModel()); 56 model.addObserver(this); 57 build(); 58 this.model = model; 59 } 49 60 50 61 protected void build() { … … 93 104 } 94 105 95 /**96 * Constructs a new {@code VersionTable}.97 * @param model model used by the history browser98 */99 public VersionTable(HistoryBrowserModel model) {100 super(model.getVersionTableModel(), new VersionTableColumnModel());101 model.addObserver(this);102 build();103 this.model = model;104 }105 106 106 // some kind of hack to prevent the table from scrolling to the 107 107 // right when clicking on the cells … … 140 140 @Override 141 141 protected int checkTableSelection(JTable table, Point p) { 142 HistoryBrowserModel.VersionTableModel model = getVersionTableModel();142 HistoryBrowserModel.VersionTableModel tableModel = getVersionTableModel(); 143 143 int row = rowAtPoint(p); 144 if (row > -1 && ! model.isLatest(row)) {145 popupMenu.prepare( model.getPrimitive(row));144 if (row > -1 && !tableModel.isLatest(row)) { 145 popupMenu.prepare(tableModel.getPrimitive(row)); 146 146 } 147 147 return row; … … 252 252 } 253 253 254 /** 255 * Renderer for history radio buttons in columns A and B. 256 */ 254 257 public static class RadioButtonRenderer extends JRadioButton implements TableCellRenderer { 255 258 … … 263 266 } 264 267 268 /** 269 * Editor for history radio buttons in columns A and B. 270 */ 265 271 public static class RadioButtonEditor extends DefaultCellEditor implements ItemListener { 266 272 … … 278 284 @Override 279 285 public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { 280 if (value == null) return null; 286 if (value == null) 287 return null; 281 288 boolean val = (Boolean) value; 282 289 btn.setSelected(val); … … 297 304 } 298 305 306 /** 307 * Renderer for history version labels, allowing to define horizontal alignment. 308 */ 299 309 public static class AlignedRenderer extends JLabel implements TableCellRenderer { 300 310
Note:
See TracChangeset
for help on using the changeset viewer.