Changeset 3286 in josm for trunk/src/org


Ignore:
Timestamp:
2010-05-29T22:21:47+02:00 (14 years ago)
Author:
stoecker
Message:

fix #4765 - improve selection history

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r3271 r3286  
    147147                nodesNo--;
    148148            }
     149            if(name.length() == 0 )
     150                name = String.valueOf(way.getId());
     151            /* note: length == 0 should no longer happen, but leave the bracket code
     152               nevertheless, who knows what future brings */
    149153            String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);
    150154            name += (name.length() > 0) ? " ("+nodes+")" : nodes;
     
    357361        int nodesNo = way.isClosed() ? way.getNumNodes() -1 : way.getNumNodes();
    358362        String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);
     363        if(sb.length() == 0 )
     364            sb.append(way.getId());
     365        /* note: length == 0 should no longer happen, but leave the bracket code
     366           nevertheless, who knows what future brings */
    359367        sb.append((sb.length() > 0) ? " ("+nodes+")" : nodes);
    360368        decorateNameWithId(sb, way);
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r3262 r3286  
    455455            if (history.getFirst().equals(selection)) return;
    456456            history.addFirst(selection);
     457            for(int i = 1; i < history.size(); ++i) {
     458                if(history.get(i).equals(selection)) {
     459                    history.remove(i);
     460                    break;
     461                }
     462            }
    457463            while (history.size() > SELECTION_HISTORY_SIZE) {
    458464                history.removeLast();
     
    685691     */
    686692    protected static class SelectionMenuItem extends JMenuItem implements ActionListener {
     693        final private DefaultNameFormatter df = DefaultNameFormatter.getInstance();
    687694        protected Collection<? extends OsmPrimitive> sel;
    688695
     
    715722                .append(trn("{0} relation", "{0} relations", relations, relations));
    716723            }
    717             setText(tr("Selection: {0}", text));
     724            if(ways + nodes + relations == 1)
     725            {
     726                text.append(": ");
     727                for(OsmPrimitive o : sel)
     728                   text.append(o.getDisplayName(df));
     729                setText(text.toString());
     730            }
     731            else
     732                setText(tr("Selection: {0}", text));
    718733            addActionListener(this);
    719734        }
Note: See TracChangeset for help on using the changeset viewer.