Changeset 5105 in josm


Ignore:
Timestamp:
Mar 18, 2012 9:33:23 PM (14 months ago)
Author:
simon04
Message:

see #6870 - Increase Readability of Available Presets/Styles (sort entries, tooltip as table, additional author/url in gray)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r4968 r5105  
    508508        } 
    509509 
    510         Class<?>[] columnClasses = {Boolean.class, SourceEntry.class}; 
    511  
    512510        @Override 
    513511        public Class<?> getColumnClass(int column) { 
    514             return isMapPaint ? columnClasses[column] : SourceEntry.class; 
     512            if (isMapPaint && column == 0) 
     513                return Boolean.class; 
     514            else return SourceEntry.class; 
    515515        } 
    516516 
     
    615615    } 
    616616 
    617     public static class ExtendedSourceEntry extends SourceEntry { 
     617    public static class ExtendedSourceEntry extends SourceEntry implements Comparable<ExtendedSourceEntry> { 
    618618        public String simpleFileName; 
    619619        public String version; 
     
    635635        } 
    636636 
     637        private void appendRow(StringBuilder s, String th, String td) { 
     638            s.append("<tr><th>").append(th).append("</th><td>").append(td).append("</td</tr>"); 
     639        } 
     640 
    637641        public String getTooltip() { 
    638             String s = tr("Short Description: {0}", getDisplayName()) + "<br>" + tr("URL: {0}", url); 
     642            StringBuilder s = new StringBuilder(); 
     643            appendRow(s, tr("Short Description:"), getDisplayName()); 
     644            appendRow(s, tr("URL:"), url); 
    639645            if (author != null) { 
    640                 s += "<br>" + tr("Author: {0}", author); 
     646                appendRow(s, tr("Author:"), author); 
    641647            } 
    642648            if (link != null) { 
    643                 s += "<br>" + tr("Webpage: {0}", link); 
     649                appendRow(s, tr("Webpage:"), link); 
    644650            } 
    645651            if (description != null) { 
    646                 s += "<br>" + tr("Description: {0}", description); 
     652                appendRow(s, tr("Description:"), description); 
    647653            } 
    648654            if (version != null) { 
    649                 s += "<br>" + tr("Version: {0}", version); 
    650             } 
    651             return "<html>" + s + "</html>"; 
     655                appendRow(s, tr("Version:"), version); 
     656            } 
     657            return "<html><style>th{text-align:right}td{width:400px}</style>" 
     658                    + "<table>" + s + "</table></html>"; 
    652659        } 
    653660 
    654661        @Override 
    655662        public String toString() { 
    656             return "<html><b>" + getDisplayName() + "</b> (" + url + ")</html>"; 
     663            return "<html><b>" + getDisplayName() + "</b>" 
     664                    + (author == null ? "" : " <span color=\"gray\">" + tr("by {0}", author) + "</color>") 
     665                    + "</html>"; 
     666        } 
     667 
     668        @Override 
     669        public int compareTo(ExtendedSourceEntry o) { 
     670            if (url.startsWith("resource") && !o.url.startsWith("resource")) { 
     671                return -1; 
     672            } 
     673            if (o.url.startsWith("resource")) { 
     674                return 1; 
     675            } else { 
     676                return getDisplayName().compareToIgnoreCase(o.getDisplayName()); 
     677            } 
    657678        } 
    658679    } 
     
    12281249        @Override 
    12291250        protected void finish() { 
     1251            Collections.sort(sources); 
    12301252            availableSourcesModel.setSources(sources); 
    12311253        } 
     
    12481270            StringBuilder s = new StringBuilder("<html><b>"); 
    12491271            if (entry.title != null) { 
    1250                 s.append(entry.title).append("</b> ("); 
     1272                s.append(entry.title).append("</b> <span color=\"gray\">"); 
    12511273            } 
    12521274            s.append(entry.url); 
    12531275            if (entry.title != null) { 
    1254                 s.append(")"); 
     1276                s.append("</span>"); 
    12551277            } 
    12561278            s.append("</html>"); 
Note: See TracChangeset for help on using the changeset viewer.