001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.preferences.advanced;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006import java.awt.Component;
007import java.awt.Dimension;
008import java.util.List;
009
010import javax.swing.JPanel;
011
012import org.openstreetmap.josm.gui.ExtendedDialog;
013import org.openstreetmap.josm.tools.WindowGeometry;
014
015/**
016 * Abstract superclass of {@link ListEditor} and {@link AbstractTableListEditor}.
017 * @param <T> type of elements
018 * @since 9505
019 */
020public abstract class AbstractListEditor<T> extends ExtendedDialog {
021
022    protected final transient PrefEntry entry;
023
024    /**
025     * Constructs a new {@code AbstractListEditor}.
026     * @param parent       The parent element that will be used for position and maximum size
027     * @param title        The text that will be shown in the window titlebar
028     * @param entry        Preference entry
029     */
030    public AbstractListEditor(Component parent, String title, PrefEntry entry) {
031        super(parent, title, new String[] {tr("OK"), tr("Cancel")});
032        this.entry = entry;
033        setButtonIcons(new String[] {"ok.png", "cancel.png"});
034        setRememberWindowGeometry(getClass().getName() + ".geometry", WindowGeometry.centerInWindow(parent, new Dimension(500, 350)));
035    }
036
037    /**
038     * Returns the list of values.
039     * @return The list of values.
040     */
041    public abstract List<T> getData();
042
043    protected abstract JPanel build();
044}