Changeset 13947 in josm for trunk


Ignore:
Timestamp:
2018-06-18T00:43:12+02:00 (6 years ago)
Author:
Don-vip
Message:

add HistoryHook

Location:
trunk/src/org/openstreetmap/josm/gui/history
Files:
1 added
1 edited

Legend:

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

    r12678 r13947  
    6464    private final Predicate<PrimitiveId> notNewPredicate = p -> !p.isNew();
    6565
     66    private static final List<HistoryHook> hooks = new ArrayList<>();
     67
    6668    protected HistoryBrowserDialogManager() {
    6769        dialogs = new HashMap<>();
     
    194196
    195197    /**
     198     * Adds a new {@code HistoryHook}.
     199     * @param hook hook to add
     200     * @return <tt>true</tt> (as specified by {@link Collection#add})
     201     * @since 13947
     202     */
     203    public static boolean addHistoryHook(HistoryHook hook) {
     204        return hooks.add(Objects.requireNonNull(hook));
     205    }
     206
     207    /**
     208     * Removes an existing {@code HistoryHook}.
     209     * @param hook hook to remove
     210     * @return <tt>true</tt> if this list contained the specified element
     211     * @since 13947
     212     */
     213    public static boolean removeHistoryHook(HistoryHook hook) {
     214        return hooks.remove(Objects.requireNonNull(hook));
     215    }
     216
     217    /**
    196218     * Show history dialog(s) for the given primitive(s).
    197219     * @param primitives The primitive(s) for which history will be displayed
    198220     */
    199221    public void showHistory(final Collection<? extends PrimitiveId> primitives) {
     222        hooks.forEach(h -> h.modifyRequestedIds(primitives));
    200223        final Collection<? extends PrimitiveId> notNewPrimitives = SubclassFilteredCollection.filter(primitives, notNewPredicate);
    201224        if (notNewPrimitives.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.