package net.sf.jabref.gui.databaseProperties;

import javax.swing.*;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

class SaveActionsListModel<FieldFormatterCleanup> implements ListModel<FieldFormatterCleanup> {

    private List<FieldFormatterCleanup> saveActions;

    private List<ListDataListener> listeners;

    public SaveActionsListModel(List<FieldFormatterCleanup> saveActions) {
        Objects.requireNonNull(saveActions);

        this.saveActions = saveActions;
        listeners = new ArrayList<>();
    }

    public void addSaveAction(FieldFormatterCleanup action) {
        saveActions.add(action);
        for (ListDataListener listener : listeners) {
            listener.intervalAdded(new ListDataEvent(action, ListDataEvent.INTERVAL_ADDED, saveActions.size(), saveActions.size()));
        }
    }

    public void removeAtIndex(int index) {
        if (index < 0 || index > saveActions.size()) {
            throw new IndexOutOfBoundsException("Index must be within 0 and " + saveActions.size() + " but was " + index);
        }

        FieldFormatterCleanup action = saveActions.remove(index);

        for (ListDataListener listener : listeners) {
            listener.intervalAdded(new ListDataEvent(action, ListDataEvent.INTERVAL_REMOVED, index, index));
        }
    }

    public List<FieldFormatterCleanup> getAllActions() {
        return saveActions;
    }


    @Override
    public int getSize() {
        return saveActions.size();
    }

    @Override
    public FieldFormatterCleanup getElementAt(int index) {
        return saveActions.get(index);
    }

    @Override
    public void addListDataListener(ListDataListener l) {
        listeners.add(l);
    }

    @Override
    public void removeListDataListener(ListDataListener l) {
        listeners.remove(l);
    }
}

@@ -686,24 +686,73 @@
 p action) %7B%0A
+        if (!saveActions.contains(action)) %7B%0A    
         save
@@ -772,16 +772,20 @@
 ction);%0A
+    
         
@@ -822,32 +822,36 @@
  : listeners) %7B%0A
+    
             list
@@ -963,24 +963,38 @@
 s.size()));%0A
+            %7D%0A
         %7D%0A  

Check for duplicates when adding save actions