Changeset 4601 in josm
- Timestamp:
- 2011-11-20T18:08:10+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/User.java
r4197 r4601 63 63 * @param name the name 64 64 */ 65 public static User 65 public static User createOsmUser(long uid, String name) { 66 66 User user = userMap.get(uid); 67 67 if (user == null) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r4556 r4601 330 330 static class UserTableModel extends DefaultTableModel { 331 331 private ArrayList<UserInfo> data; 332 private JLabel greenCheckmark;333 private JLabel greyCheckmark;334 private JLabel redX;335 private JLabel empty;336 332 337 333 public UserTableModel() { 338 334 setColumnIdentifiers(new String[]{tr("Author"),tr("# Objects"),"%", tr("CT")}); 339 335 data = new ArrayList<UserInfo>(); 340 greenCheckmark = new JLabel(ImageProvider.get("misc", "green_check.png"));341 greenCheckmark.setToolTipText(tr("Accepted"));342 greyCheckmark = new JLabel(ImageProvider.get("misc", "grey_check.png"));343 greyCheckmark.setToolTipText("Auto-accepted");344 redX = new JLabel(ImageProvider.get("misc", "red_x.png"));345 redX.setToolTipText("Declined");346 empty = new JLabel("");347 empty.setToolTipText("Undecided");348 336 } 349 337 … … 386 374 case 1: /* count */ return info.count; 387 375 case 2: /* percent */ return NumberFormat.getPercentInstance().format(info.percent); 388 case 3: /* relicensing status */ 389 switch(info.getRelicensingStatus()) { 390 case User.STATUS_AGREED: return greenCheckmark; 391 case User.STATUS_AUTO_AGREED: return greyCheckmark; 392 case User.STATUS_NOT_AGREED: return redX; 393 default: return empty; // Undecided or unknown? 394 } 376 case 3: /* relicensing status */ return getRelicensingStatusIcon(info.getRelicensingStatus()); 395 377 } 396 378 return null; … … 429 411 } 430 412 } 413 414 private static JLabel greenCheckmark; 415 private static JLabel greyCheckmark; 416 private static JLabel redX; 417 private static JLabel empty; 418 419 public static JLabel getRelicensingStatusIcon(int status) { 420 switch(status) { 421 case User.STATUS_AGREED: 422 if (greenCheckmark == null) { 423 greenCheckmark = new JLabel(ImageProvider.get("misc", "green_check.png")); 424 greenCheckmark.setToolTipText(tr("Accepted")); 425 } 426 return greenCheckmark; 427 case User.STATUS_AUTO_AGREED: 428 if (greyCheckmark == null) { 429 greyCheckmark = new JLabel(ImageProvider.get("misc", "grey_check.png")); 430 greyCheckmark.setToolTipText("Auto-accepted"); 431 } 432 return greyCheckmark; 433 case User.STATUS_NOT_AGREED: 434 if (redX == null) { 435 redX = new JLabel(ImageProvider.get("misc", "red_x.png")); 436 redX.setToolTipText("Declined"); 437 } 438 return redX; 439 default: 440 if (empty == null) { 441 empty = new JLabel(""); 442 empty.setToolTipText("Undecided"); 443 } 444 } 445 return empty; // Undecided or unknown? 446 } 431 447 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowser.java
r4598 r4601 96 96 97 97 pane.setOneTouchExpandable(true); 98 pane.setDividerLocation( 200);98 pane.setDividerLocation(300); 99 99 100 100 Dimension minimumSize = new Dimension(100, 50); -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r4598 r4601 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.text.SimpleDateFormat; 6 7 import java.util.ArrayList; 7 8 import java.util.Collections; … … 18 19 import org.openstreetmap.josm.data.osm.Relation; 19 20 import org.openstreetmap.josm.data.osm.RelationMember; 21 import org.openstreetmap.josm.data.osm.User; 20 22 import org.openstreetmap.josm.data.osm.Way; 21 23 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; … … 36 38 import org.openstreetmap.josm.gui.MapView; 37 39 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 40 import org.openstreetmap.josm.gui.dialogs.UserListDialog; 38 41 import org.openstreetmap.josm.gui.layer.Layer; 39 42 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 412 415 switch (column) { 413 416 case 0: 417 return Long.toString(getPrimitive(row).getVersion()); 418 case 1: 414 419 return isReferencePointInTime(row); 415 case 1:420 case 2: 416 421 return isCurrentPointInTime(row); 417 case 2: 418 if(history == null) 422 case 3: 423 long uId = getPrimitive(row).getUid(); 424 User user = User.getById(uId); 425 int status; 426 if (user == null) { 427 status = User.STATUS_UNKNOWN; 428 } else { 429 status = user.getRelicensingStatus(); 430 } 431 return UserListDialog.getRelicensingStatusIcon(status); 432 case 4: { 433 HistoryOsmPrimitive p = getPrimitive(row); 434 if (p != null) 435 return new SimpleDateFormat().format(p.getTimestamp()); 419 436 return null; 420 if (row < history.getNumVersions()) 421 return history.get(row); 422 if (row == history.getNumVersions()) 423 return latest; 424 return null; 437 } 438 case 5: { 439 HistoryOsmPrimitive p = getPrimitive(row); 440 if (p != null) 441 return "<html>"+p.getUser() + " <font color=gray>(" + p.getUid() + ")</font></html>"; 442 return null; 443 } 425 444 } 426 445 return null; … … 431 450 if (!((Boolean) aValue)) return; 432 451 switch (column) { 433 case 0:452 case 1: 434 453 setReferencePointInTime(row); 435 454 break; 436 case 1:455 case 2: 437 456 setCurrentPointInTime(row); 438 457 break; 458 default: 459 return; 439 460 } 440 461 fireTableDataChanged(); … … 443 464 @Override 444 465 public boolean isCellEditable(int row, int column) { 445 return column <2;466 return column >= 1 && column <= 2; 446 467 } 447 468 … … 491 512 492 513 public HistoryOsmPrimitive getPrimitive(int row) { 514 if (history == null) 515 return null; 493 516 return isLatest(row) ? latest : history.get(row); 494 517 } … … 507 530 @Override 508 531 public int getColumnCount() { 509 return 3;532 return 6; 510 533 } 511 534 } -
trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
r4598 r4601 5 5 6 6 import java.awt.Component; 7 import java.awt.Dimension; 8 import java.awt.Rectangle; 7 9 import java.awt.event.ActionEvent; 8 10 import java.awt.event.ItemEvent; … … 16 18 import javax.swing.DefaultListSelectionModel; 17 19 import javax.swing.JCheckBox; 20 import javax.swing.JLabel; 18 21 import javax.swing.JPopupMenu; 19 22 import javax.swing.JRadioButton; … … 21 24 import javax.swing.ListSelectionModel; 22 25 import javax.swing.SwingConstants; 26 import javax.swing.UIManager; 23 27 import javax.swing.event.ListSelectionEvent; 24 28 import javax.swing.event.ListSelectionListener; 25 29 import javax.swing.event.TableModelEvent; 30 import javax.swing.event.TableModelListener; 26 31 import javax.swing.table.TableCellRenderer; 27 32 … … 38 43 39 44 protected void build() { 45 getTableHeader().setFont(getTableHeader().getFont().deriveFont(9f)); 40 46 setRowSelectionAllowed(false); 47 setShowGrid(false); 48 setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 49 setBackground(UIManager.getColor("Button.background")); 50 setIntercellSpacing(new Dimension(6, 0)); 51 putClientProperty("terminateEditOnFocusLost", true); 41 52 popupMenu = new VersionTablePopupMenu(); 42 53 addMouseListener(new PopupMenuTrigger()); 54 getModel().addTableModelListener(new TableModelListener() { 55 @Override 56 public void tableChanged(TableModelEvent e) { 57 adjustColumnWidth(VersionTable.this, 0); 58 adjustColumnWidth(VersionTable.this, 4); 59 adjustColumnWidth(VersionTable.this, 5); 60 } 61 }); 43 62 } 44 63 … … 47 66 model.addObserver(this); 48 67 build(); 68 } 69 70 // some kind of hack to prevent the table from scrolling to the 71 // right when clicking on the cells 72 @Override 73 public void scrollRectToVisible(Rectangle aRect) { 74 super.scrollRectToVisible(new Rectangle(0, aRect.y, aRect.width, aRect.height)); 49 75 } 50 76 … … 135 161 136 162 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 137 HistoryBrowserModel.VersionTableModel model = (HistoryBrowserModel.VersionTableModel)table.getModel();138 163 setSelected(value != null && (Boolean)value); 139 164 setHorizontalAlignment(SwingConstants.CENTER); … … 169 194 } 170 195 } 196 197 public static class LabelRenderer implements TableCellRenderer { 198 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 199 return (Component) value; 200 } 201 } 202 203 public static class AlignedRenderer extends JLabel implements TableCellRenderer { 204 public AlignedRenderer(int hAlignment) { 205 setHorizontalAlignment(hAlignment); 206 } 207 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 208 String v = value.toString(); 209 setText(v); 210 return this; 211 } 212 } 213 214 private static void adjustColumnWidth(JTable tbl, int col) { 215 int maxwidth = 0; 216 217 for (int row=0; row<tbl.getRowCount(); row++) { 218 TableCellRenderer tcr = tbl.getCellRenderer(row, col); 219 Object val = tbl.getValueAt(row, col); 220 Component comp = tcr.getTableCellRendererComponent(tbl, val, false, false, row, col); 221 maxwidth = Math.max(comp.getPreferredSize().width, maxwidth); 222 } 223 TableCellRenderer tcr = tbl.getTableHeader().getDefaultRenderer(); 224 Object val = tbl.getColumnModel().getColumn(col).getHeaderValue(); 225 Component comp = tcr.getTableCellRendererComponent(tbl, val, false, false, -1, col); 226 maxwidth = Math.max(comp.getPreferredSize().width, maxwidth); 227 228 int spacing = tbl.getIntercellSpacing().width; 229 tbl.getColumnModel().getColumn(col).setPreferredWidth(maxwidth + spacing); 230 } 231 171 232 } -
trunk/src/org/openstreetmap/josm/gui/history/VersionTableColumnModel.java
r4598 r4601 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import javax.swing.SwingConstants; 6 7 import javax.swing.table.DefaultTableColumnModel; 7 8 import javax.swing.table.TableCellRenderer; 8 9 import javax.swing.table.TableColumn; 10 9 11 /** 10 12 * The {@see TableColumnModel} for the table with the list of versions … … 14 16 protected void createColumns() { 15 17 TableColumn col = null; 16 TableCellRenderer renderer = new VersionTableCellRenderer();17 18 VersionTable.RadioButtonRenderer bRenderer = new VersionTable.RadioButtonRenderer(); 18 19 19 // column 0 - Reverence20 // column 0 - Version 20 21 col = new TableColumn(0); 22 /* translation note: 3 letter abbr. for "Version" */ 23 col.setHeaderValue(tr("Ver")); 24 col.setCellRenderer(new VersionTable.AlignedRenderer(SwingConstants.CENTER)); 25 col.setResizable(false); 26 addColumn(col); 27 // column 1 - Reverence 28 col = new TableColumn(1); 29 col.setHeaderValue(tr("A")); 21 30 col.setCellRenderer(bRenderer); 22 31 col.setCellEditor(new VersionTable.RadioButtonEditor()); 23 col.setMaxWidth(1 );32 col.setMaxWidth(18); 24 33 col.setResizable(false); 25 34 addColumn(col); 26 // column 1 - Current 27 col = new TableColumn(1); 35 // column 2 - Current 36 col = new TableColumn(2); 37 col.setHeaderValue(tr("B")); 28 38 col.setCellRenderer(bRenderer); 29 39 col.setCellEditor(new VersionTable.RadioButtonEditor()); 30 col.set MaxWidth(1);40 col.setPreferredWidth(18); 31 41 col.setResizable(false); 32 42 addColumn(col); 33 // column 2 - Rest 34 col = new TableColumn(2); 35 col.setHeaderValue(tr("Version")); 36 col.setCellRenderer(renderer); 43 // column 3 - CT state 44 col = new TableColumn(3); 45 /* translation note: short for "Contributor Terms" */ 46 col.setHeaderValue(tr("CT")); 47 col.setCellRenderer(new VersionTable.LabelRenderer()); 48 col.setPreferredWidth(22); 49 col.setResizable(false); 50 addColumn(col); 51 // column 4 - Date 52 col = new TableColumn(4); 53 col.setHeaderValue(tr("Date")); 54 col.setResizable(false); 55 addColumn(col); 56 // column 5 - User 57 col = new TableColumn(5); 58 col.setHeaderValue(tr("User")); 59 col.setResizable(false); 37 60 addColumn(col); 38 61 }
Note:
See TracChangeset
for help on using the changeset viewer.