Changeset 9149 in josm for trunk/src/org
- Timestamp:
- 2015-12-25T20:01:23+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/properties
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r8540 r9149 9 9 import java.awt.Component; 10 10 import java.awt.Font; 11 import java.util.Collection; 11 12 import java.util.Map; 12 13 import java.util.Objects; 14 import java.util.concurrent.CopyOnWriteArrayList; 13 15 14 16 import javax.swing.JLabel; … … 16 18 import javax.swing.UIDefaults; 17 19 import javax.swing.table.DefaultTableCellRenderer; 20 import javax.swing.table.TableCellRenderer; 18 21 19 22 import org.openstreetmap.josm.Main; … … 25 28 */ 26 29 public class PropertiesCellRenderer extends DefaultTableCellRenderer { 30 31 private final Collection<TableCellRenderer> customRenderer = new CopyOnWriteArrayList<>(); 27 32 28 33 private void setColors(Component c, String key, boolean isSelected) { … … 45 50 @Override 46 51 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { 52 for (TableCellRenderer renderer : customRenderer) { 53 final Component component = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 54 if (component != null) { 55 return component; 56 } 57 } 47 58 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 48 59 if (value == null) … … 106 117 return c; 107 118 } 119 120 /** 121 * Adds a custom table cell renderer to render cells of the tags table. 122 * 123 * If the renderer is not capable performing a {@link TableCellRenderer#getTableCellRendererComponent}, 124 * it should return {@code null} to fall back to the 125 * {@link PropertiesCellRenderer#getTableCellRendererComponent default implementation}. 126 * @param renderer the renderer to add 127 * @since 9149 128 */ 129 public void addCustomRenderer(TableCellRenderer renderer) { 130 customRenderer.add(renderer); 131 } 132 133 /** 134 * Removes a custom table cell renderer. 135 * @param renderer the renderer to remove 136 * @since 9149 137 */ 138 public void removeCustomRenderer(TableCellRenderer renderer) { 139 customRenderer.remove(renderer); 140 } 108 141 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r9147 r9149 48 48 import javax.swing.table.DefaultTableCellRenderer; 49 49 import javax.swing.table.DefaultTableModel; 50 import javax.swing.table.TableCellRenderer; 50 51 import javax.swing.table.TableColumnModel; 51 52 import javax.swing.table.TableModel; … … 137 138 */ 138 139 private final ReadOnlyTableModel tagData = new ReadOnlyTableModel(); 140 private final PropertiesCellRenderer cellRenderer = new PropertiesCellRenderer(); 139 141 private final TableRowSorter<ReadOnlyTableModel> tagRowSorter = new TableRowSorter<>(tagData); 140 142 private final JosmTextField tagTableFilter; … … 304 306 tagTable.getTableHeader().setReorderingAllowed(false); 305 307 306 PropertiesCellRenderer cellRenderer = new PropertiesCellRenderer();307 308 tagTable.getColumnModel().getColumn(0).setCellRenderer(cellRenderer); 308 309 tagTable.getColumnModel().getColumn(1).setCellRenderer(cellRenderer); … … 818 819 819 820 /** 821 * Adds a custom table cell renderer to render cells of the tags table. 822 * 823 * If the renderer is not capable performing a {@link TableCellRenderer#getTableCellRendererComponent}, 824 * it should return {@code null} to fall back to the 825 * {@link PropertiesCellRenderer#getTableCellRendererComponent default implementation}. 826 * @param renderer the renderer to add 827 * @since 9149 828 */ 829 public void addCustomPropertiesCellRenderer(TableCellRenderer renderer) { 830 cellRenderer.addCustomRenderer(renderer); 831 } 832 833 /** 834 * Removes a custom table cell renderer. 835 * @param renderer the renderer to remove 836 * @since 9149 837 */ 838 public void removeCustomPropertiesCellRenderer(TableCellRenderer renderer) { 839 cellRenderer.removeCustomRenderer(renderer); 840 } 841 842 /** 820 843 * Class that watches for mouse clicks 821 844 * @author imi
Note:
See TracChangeset
for help on using the changeset viewer.