Ignore:
Timestamp:
03.12.2009 19:02:25 (2 years ago)
Author:
Gubaer
Message:

fixed #3400: relation editor: improvement to highlight an element
fixed #3873: Feature request: download selected elements in relation editor
New: Dbl-Click in member table to set the map selection to this member
New: Ctrl-Dbl-Clik in member table to add the member to the the map selection
New: Download selected incomplete members only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableCellRenderer.java

    r2512 r2563  
    44import java.awt.Color; 
    55import java.awt.Component; 
    6 import java.util.ArrayList; 
    7 import java.util.Collections; 
    86 
    97import javax.swing.JLabel; 
    108import javax.swing.JTable; 
     9import javax.swing.UIManager; 
    1110import javax.swing.table.TableCellRenderer; 
    1211 
     
    1817 */ 
    1918public abstract class MemberTableCellRenderer extends JLabel implements TableCellRenderer { 
    20     public final static Color BGCOLOR_SELECTED = new Color(143, 170, 255); 
    2119    public final static Color BGCOLOR_EMPTY_ROW = new Color(234, 234, 234); 
     20    public final static Color BGCOLOR_IN_JOSM_SELECTION = new Color(235,255,177); 
    2221 
    2322    public final static Color BGCOLOR_NOT_IN_OPPOSITE = new Color(255, 197, 197); 
    24     public final static Color BGCOLOR_DOUBLE_ENTRY = new Color(255, 234, 213); 
     23    public final static Color BGCOLOR_DOUBLE_ENTRY = new Color(254,226,214); 
    2524 
    2625    /** 
     
    3231    } 
    3332 
    34     public String buildToolTipText(OsmPrimitive primitive) { 
    35         StringBuilder sb = new StringBuilder(); 
    36         sb.append("<html>"); 
    37         sb.append("<strong>id</strong>=").append(primitive.getId()).append("<br>"); 
    38         ArrayList<String> keyList = new ArrayList<String>(primitive.keySet()); 
    39         Collections.sort(keyList); 
    40         for (int i = 0; i < keyList.size(); i++) { 
    41             if (i > 0) { 
    42                 sb.append("<br>"); 
    43             } 
    44             String key = keyList.get(i); 
    45             sb.append("<strong>").append(key).append("</strong>").append("="); 
    46             String value = primitive.get(key); 
    47             while (value.length() != 0) { 
    48                 sb.append(value.substring(0, Math.min(50, value.length()))); 
    49                 if (value.length() > 50) { 
    50                     sb.append("<br>"); 
    51                     value = value.substring(50); 
    52                 } else { 
    53                     value = ""; 
    54                 } 
    55             } 
    56         } 
    57         sb.append("</html>"); 
    58         return sb.toString(); 
    59     } 
    60  
    6133    /** 
    6234     * reset the renderer 
    6335     */ 
    6436    protected void reset() { 
    65         setBackground(Color.WHITE); 
    66         setForeground(Color.BLACK); 
     37        setBackground(UIManager.getColor("Table.background")); 
     38        setForeground(UIManager.getColor("Table.foreground")); 
    6739        setBorder(null); 
    6840        setIcon(null); 
     
    7143 
    7244    protected void renderBackground(MemberTableModel model, OsmPrimitive primitive, boolean isSelected) { 
    73         Color bgc = Color.WHITE; 
     45        Color bgc = UIManager.getColor("Table.background"); 
    7446        if (isSelected) { 
    75             bgc = BGCOLOR_SELECTED; 
     47            bgc = UIManager.getColor("Table.selectionBackground"); 
     48        } else if (primitive != null && model.isInJosmSelection(primitive)) { 
     49            bgc = BGCOLOR_IN_JOSM_SELECTION; 
    7650        } else if (primitive != null && model.getNumMembersWithPrimitive(primitive) > 1) { 
    7751            bgc = BGCOLOR_DOUBLE_ENTRY; 
     
    8155 
    8256    protected void renderForeground(boolean isSelected) { 
    83         Color fgc = Color.BLACK; 
     57        Color fgc; 
     58        if (isSelected) { 
     59            fgc = UIManager.getColor("Table.selectionForeground"); 
     60        } else { 
     61            fgc = UIManager.getColor("Table.foreground"); 
     62        } 
    8463        setForeground(fgc); 
    8564    } 
Note: See TracChangeset for help on using the changeset viewer.