001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.dialogs.relation.actions;
003
004/**
005 * This interface can be used to register the event listeners for a
006 * {@link AbstractRelationEditorAction}.
007 * <p>
008 * It holds common constants that are often used.
009 *
010 * @author Michael Zangl
011 * @since 14027
012 */
013@FunctionalInterface
014public interface IRelationEditorUpdateOn {
015    /**
016     * Update when the member table contents change
017     */
018    IRelationEditorUpdateOn MEMBER_TABLE_CHANGE = (editor, action) -> editor.getMemberTableModel()
019            .addTableModelListener(action);
020    /**
021     * Update upon a member table selection change
022     */
023    IRelationEditorUpdateOn MEMBER_TABLE_SELECTION = (editor, action) -> editor.getMemberTable().getSelectionModel()
024            .addListSelectionListener(action);
025
026    /**
027     * Update when a tag of the relation changed
028     */
029    IRelationEditorUpdateOn TAG_CHANGE = (editor, action) -> editor.getTagModel().addPropertyChangeListener(action);
030
031    /**
032     * Update when a relation changed
033     */
034    IRelationEditorUpdateOn SELECTION_TABLE_CHANGE = (editor, action) -> editor.getSelectionTableModel()
035            .addTableModelListener(action);
036
037    /**
038     * Registers the given action as listener on the relation editor.
039     * @param editor The relation editor to register the listeners on
040     * @param action The action that should be registered
041     */
042    void register(IRelationEditorActionAccess editor, AbstractRelationEditorAction action);
043}