001package jmri.jmrit.logixng.tools.swing; 002 003import java.awt.event.*; 004import java.util.*; 005import java.util.List; 006 007import jmri.InstanceManager; 008import jmri.jmrit.logixng.*; 009 010/** 011 * Editor of the clipboard 012 * 013 * @author Daniel Bergqvist 2020 014 */ 015public class ClipboardEditor extends TreeEditor { 016 017 /** 018 * Maintain a list of listeners -- normally only one. 019 */ 020 private final List<ClipboardEventListener> listenerList = new ArrayList<>(); 021 022 /** 023 * This contains a list of commands to be processed by the listener 024 * recipient. 025 */ 026 final HashMap<String, String> clipboardData = new HashMap<>(); 027 028 /** 029 * Construct a ConditionalEditor. 030 */ 031 public ClipboardEditor() { 032 super(InstanceManager.getDefault(LogixNG_Manager.class).getClipboard().getFemaleSocket(), 033 EnableClipboard.DisableClipboard, 034 EnableRootRemoveCutCopy.EnableRootRemoveCutCopy, 035 EnableRootPopup.DisableRootPopup, 036 EnableExecuteEvaluate.DisableExecuteEvaluate 037 ); 038 039 ClipboardEditor.this.setTitle(Bundle.getMessage("TitleClipboardEditor")); 040 041 ClipboardEditor.this.setRootVisible(false); 042 } 043 044 /** {@inheritDoc} */ 045 @Override 046 public void windowClosed(WindowEvent e) { 047 clipboardData.clear(); 048 clipboardData.put("Finish", "Clipboard"); // NOI18N 049 fireClipboardEvent(); 050 } 051 052 public void addClipboardEventListener(ClipboardEventListener listener) { 053 listenerList.add(listener); 054 } 055 056 /** 057 * Notify the listeners to check for new data. 058 */ 059 void fireClipboardEvent() { 060 for (ClipboardEventListener l : listenerList) { 061 l.clipboardEventOccurred(); 062 } 063 } 064 065 066 public interface ClipboardEventListener extends EventListener { 067 068 public void clipboardEventOccurred(); 069 } 070 071 072// private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(ClipboardEditor.class); 073 074}