Ignore:
Timestamp:
2016-01-29T11:55:03+01:00 (8 years ago)
Author:
bastiK
Message:

applied #12409 - arrow on edit relation button lists recent relations (patch by kolesar)

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

Legend:

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

    r9253 r9668  
    9090    }
    9191
    92     public void createArrow(ActionListener listener) {
     92    public BasicArrowButton createArrow(ActionListener listener) {
    9393        setMargin(new Insets(0, 0, 0, 0));
    9494        BasicArrowButton arrowButton = new BasicArrowButton(SwingConstants.SOUTH, null, null, Color.BLACK, null);
     
    9696        add(arrowButton, BorderLayout.EAST);
    9797        arrowButton.addActionListener(listener);
     98        return arrowButton;
    9899    }
    99100
  • trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

    r9365 r9668  
    4242import org.openstreetmap.josm.actions.relation.DuplicateRelationAction;
    4343import org.openstreetmap.josm.actions.relation.EditRelationAction;
     44import org.openstreetmap.josm.actions.relation.RecentRelationsAction;
    4445import org.openstreetmap.josm.actions.relation.SelectMembersAction;
    4546import org.openstreetmap.josm.actions.relation.SelectRelationAction;
     
    123124    private final transient HighlightHelper highlightHelper = new HighlightHelper();
    124125    private final boolean highlightEnabled = Main.pref.getBoolean("draw.target-highlight", true);
     126    private RecentRelationsAction recentRelationsAction;
    125127
    126128    /**
     
    169171        pane.add(filter, BorderLayout.NORTH);
    170172        pane.add(new JScrollPane(displaylist), BorderLayout.CENTER);
     173
     174        SideButton editButton = new SideButton(editAction, false);
     175        recentRelationsAction = new RecentRelationsAction(editButton);
     176
    171177        createLayout(pane, false, Arrays.asList(new SideButton[]{
    172178                new SideButton(newAction, false),
    173                 new SideButton(editAction, false),
     179                editButton,
    174180                new SideButton(duplicateAction, false),
    175181                new SideButton(deleteRelationsAction, false),
     
    191197
    192198        updateActionsRelationLists();
     199    }
     200
     201    public void enableRecentRelations() {
     202        recentRelationsAction.enableArrow();
    193203    }
    194204
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java

    r9659 r9668  
    6767        this.layer = layer;
    6868        setRelation(relation);
     69        layer.removeRecentRelation(relation);
    6970    }
    7071
     
    190191        this.support.removePropertyChangeListener(listener);
    191192    }
     193
     194    @Override
     195    public void dispose() {
     196        layer.setRecentRelation(relation);
     197        super.dispose();
     198    }
    192199}
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r9481 r9668  
    2525import java.util.HashMap;
    2626import java.util.HashSet;
     27import java.util.LinkedHashMap;
     28import java.util.LinkedList;
    2729import java.util.List;
    2830import java.util.Map;
     
    7577import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
    7678import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
     79import org.openstreetmap.josm.data.preferences.IntegerProperty;
    7780import org.openstreetmap.josm.data.projection.Projection;
    7881import org.openstreetmap.josm.data.validation.TestError;
     
    122125    public final List<TestError> validationErrors = new ArrayList<>();
    123126
     127    public static final int DEFAULT_RECENT_RELATIONS_NUMBER = 20;
     128    public static final IntegerProperty PROPERTY_RECENT_RELATIONS_NUMBER = new IntegerProperty("properties.last-closed-relations-size",
     129            DEFAULT_RECENT_RELATIONS_NUMBER);
     130
     131    /** List of recent relations */
     132    private final Map<Relation, Void> recentRelations = new LinkedHashMap<Relation, Void>(PROPERTY_RECENT_RELATIONS_NUMBER.get()+1, 1.1f, true) {
     133        @Override
     134        protected boolean removeEldestEntry(Map.Entry<Relation, Void> eldest) {
     135            return size() > PROPERTY_RECENT_RELATIONS_NUMBER.get();
     136        }
     137    };
     138
     139    /**
     140     * Returns list of recently closed relations or null if none.
     141     */
     142    public ArrayList<Relation> getRecentRelations() {
     143        ArrayList<Relation> list = new ArrayList<Relation>(recentRelations.keySet());
     144        Collections.reverse(list);
     145        return list;
     146    }
     147
     148    public void setRecentRelation(Relation relation) {
     149        recentRelations.put(relation, null);
     150        Main.map.relationListDialog.enableRecentRelations();
     151    }
     152
     153    public void removeRecentRelation(Relation relation) {
     154        recentRelations.remove(relation);
     155        Main.map.relationListDialog.enableRecentRelations();
     156    }
     157
    124158    protected void setRequiresSaveToFile(boolean newValue) {
    125159        boolean oldValue = requiresSaveToFile;
Note: See TracChangeset for help on using the changeset viewer.