Changeset 10637 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2016-07-25T20:56:38+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/datatransfer/data/TagTransferData.java
r10604 r10637 40 40 41 41 /** 42 * Create a new {@link TagTransferData} object with the given tags. 43 * @param tags The tags. 44 * @since 10637 45 */ 46 public TagTransferData(Map<String, String> tags) { 47 this.tags.putAll(tags); 48 } 49 50 /** 42 51 * Gets all tags contained in this data. 43 52 * @return The tags. -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r10627 r10637 582 582 @Override 583 583 public Object getValueAt(int row, int column) { 584 return getKeyAt(row); 585 } 586 587 /** 588 * Get the key for the given row. 589 * @param row The row 590 * @return The key in that row. 591 * @since 10637 592 */ 593 public String getKeyAt(int row) { 584 594 return keys.get(row); 585 595 } … … 637 647 @Override 638 648 public int getColumnCount() { 639 return 1;649 return 2; 640 650 } 641 651 } -
trunk/src/org/openstreetmap/josm/gui/history/SelectionSynchronizer.java
r8510 r10637 13 13 14 14 private final Set<ListSelectionModel> participants; 15 private boolean preventRecursion = false; 15 16 16 17 /** … … 32 33 @Override 33 34 public void valueChanged(ListSelectionEvent e) { 35 if (preventRecursion) { 36 return; 37 } 38 preventRecursion = true; 34 39 DefaultListSelectionModel referenceModel = (DefaultListSelectionModel) e.getSource(); 35 40 int i = referenceModel.getMinSelectionIndex(); … … 40 45 model.setSelectionInterval(i, i); 41 46 } 47 preventRecursion = false; 42 48 } 43 49 } -
trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java
r7801 r10637 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.history; 3 4 import java.awt.event.FocusEvent; 5 import java.awt.event.FocusListener; 3 6 4 7 import javax.swing.JTable; … … 16 19 */ 17 20 public class TagInfoViewer extends HistoryViewerPanel { 21 private static final class RepaintOnFocusChange implements FocusListener { 22 @Override 23 public void focusLost(FocusEvent e) { 24 repaintSelected(e); 25 } 26 27 @Override 28 public void focusGained(FocusEvent e) { 29 repaintSelected(e); 30 } 31 32 private static void repaintSelected(FocusEvent e) { 33 // we would only need the selected rows, but this is easier: 34 e.getComponent().repaint(); 35 } 36 } 37 38 /** 39 * Constructs a new {@code TagInfoViewer}. 40 * @param model The history browsing model 41 */ 42 public TagInfoViewer(HistoryBrowserModel model) { 43 super(model); 44 } 18 45 19 46 @Override … … 24 51 ); 25 52 table.setName("table.referencetagtable"); 26 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 27 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel()); 53 setUpDataTransfer(table); 28 54 return table; 29 55 } … … 36 62 ); 37 63 table.setName("table.currenttagtable"); 38 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 39 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel()); 64 setUpDataTransfer(table); 40 65 return table; 41 66 } 42 67 43 /** 44 * Constructs a new {@code TagInfoViewer}. 45 * @param model The history browsing model 46 */ 47 public TagInfoViewer(HistoryBrowserModel model) { 48 super(model); 68 private void setUpDataTransfer(JTable table) { 69 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 70 selectionSynchronizer.participateInSynchronizedSelection(table.getSelectionModel()); 71 table.setTransferHandler(new TagInfoTransferHandler()); 72 table.addFocusListener(new RepaintOnFocusChange()); 49 73 } 50 74 } -
trunk/src/org/openstreetmap/josm/gui/history/TagTableCellRenderer.java
r10217 r10637 17 17 */ 18 18 public class TagTableCellRenderer extends JLabel implements TableCellRenderer { 19 public static final Color BGCOLOR_SELECTED = new Color(143, 170, 255); 19 /** 20 * The background color for a selected row that has the focus. 21 */ 22 public static final Color BGCOLOR_SELECTED_FOCUS = new Color(0xff8faaff); 23 /** 24 * The background color for a selected row while the table is not focused. 25 */ 26 public static final Color BGCOLOR_SELECTED = new Color(0xffafc2ff); 20 27 21 28 /** … … 26 33 } 27 34 28 protected void setBackgroundReadable(String key, HistoryBrowserModel.TagTableModel model, boolean isSelected, boolean isValue) { 35 protected void setBackgroundReadable(String key, HistoryBrowserModel.TagTableModel model, boolean isSelected, boolean hasFocus, 36 boolean isValue) { 29 37 Color bgColor = UIManager.getColor("Table.background"); 30 38 if (!model.hasTag(key) && model.isCurrentPointInTime() … … 38 46 } 39 47 if (isSelected) { 40 bgColor = BGCOLOR_SELECTED; 48 if (hasFocus) { 49 bgColor = BGCOLOR_SELECTED_FOCUS; 50 } else { 51 bgColor = BGCOLOR_SELECTED; 52 } 41 53 } 42 54 … … 54 66 HistoryBrowserModel.TagTableModel model = getTagTableModel(table); 55 67 56 switch(column) { 57 case 0: 58 // the name column 59 setText(model.hasTag(key) ? key : ""); 60 setToolTipText(getText()); 61 setBackgroundReadable(key, model, isSelected, false); 62 break; 63 case 1: 64 // the value column 65 setText(model.hasTag(key) ? model.getValue(key) : ""); 66 setToolTipText(getText()); 67 setBackgroundReadable(key, model, isSelected, true); 68 break; 69 default: // Do nothing 68 String text = ""; 69 if (model.hasTag(key)) { 70 switch(column) { 71 case TagTableColumnModel.COLUMN_KEY: 72 // the name column 73 text = key; 74 break; 75 case TagTableColumnModel.COLUMN_VALUE: 76 // the value column 77 text = model.getValue(key); 78 break; 79 default: // Do nothing 80 } 70 81 } 71 82 83 setText(text); 84 setToolTipText(text); 85 setBackgroundReadable(key, model, isSelected, table.hasFocus(), column == TagTableColumnModel.COLUMN_VALUE); 72 86 return this; 73 87 } -
trunk/src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java
r10308 r10637 12 12 */ 13 13 public class TagTableColumnModel extends DefaultTableColumnModel { 14 protected static final int COLUMN_KEY = 0; 15 protected static final int COLUMN_VALUE = 1; 14 16 15 17 /**
Note:
See TracChangeset
for help on using the changeset viewer.