/** * Returns the singleton instance of this class, lazily creating it if * necessary.<p> * * This method should only be called on the EDT. * * @return The singleton instance of this class. */ public static ClipboardHistory get() { if (instance==null) { instance = new ClipboardHistory(); } return instance; }
/** * Inserts the selected item into the editor and disposes of this popup. */ private void insertSelectedItem() { Object lvp = list.getSelectedValue(); if (lvp!=null) { listener.uninstallAndHide(); String text = ((LabelValuePair)lvp).value; textArea.replaceSelection(text); ClipboardHistory.get().add(text); // Move this item to the top } }
/** * Sets the maximum number of clipboard values remembered. * * @param maxSize The maximum number of clipboard values to remember. * @throws IllegalArgumentException If <code>maxSize</code> is not greater * than zero. * @see #getMaxSize() */ public void setMaxSize(int maxSize) { if (maxSize<=0) { throw new IllegalArgumentException("Maximum size must be >= 0"); } this.maxSize = maxSize; trim(); }
public ClipboardHistoryAction(String name, Icon icon, String desc, Integer mnemonic, KeyStroke accelerator) { super(name, icon, desc, mnemonic, accelerator); clipboardHistory = ClipboardHistory.get(); }
@Override public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Window owner = SwingUtilities.getWindowAncestor(textArea); ClipboardHistoryPopup popup = new ClipboardHistoryPopup(owner, textArea); popup.setContents(clipboardHistory.getHistory()); popup.setVisible(true); }
public ClipboardHistoryAction() { super(clipboardHistoryAction); clipboardHistory = ClipboardHistory.get(); }
@Override public void actionPerformedImpl(ActionEvent e, RTextArea textArea) { Window owner = SwingUtilities.getWindowAncestor(textArea); ClipboardHistoryPopup popup = new ClipboardHistoryPopup(owner, textArea); popup.setContents(clipboardHistory.getHistory()); popup.setVisible(true); }
/** * This method is called after data has been exported. This method should * remove the data that was transfered if the action was MOVE. * * @param source The component that was the source of the data. * @param data The data that was transferred or possibly null * if the action is <code>NONE</code>. * @param action The actual action that was performed. */ @Override protected void exportDone(JComponent source, Transferable data, int action) { // only remove the text if shouldRemove has not been set to // false by importData and only if the action is a move if (shouldRemove && action == MOVE) { TextTransferable t = (TextTransferable)data; t.removeText(); if (withinSameComponent) { ((RTextArea)source).endAtomicEdit(); withinSameComponent = false; } } exportComp = null; if (data instanceof TextTransferable) { ClipboardHistory.get().add(((TextTransferable)data).getPlainData()); } }
public ClipboardHistoryAction(String name, Icon icon, String desc, Integer mnemonic, KeyStroke accelerator) { super(name, icon, desc, mnemonic, accelerator); clipboardHistory = ClipboardHistory.get(); }
/** * Adds an entry to the clipboard history. * * @param str The text to add. * @see #getHistory() */ public void add(String str) { int size = history.size(); if (size==0) { history.add(str); } else { int index = history.indexOf(str); if (index!=size-1) { if (index>-1) { history.remove(index); } history.add(str); } trim(); } }
/** * Returns the singleton instance of this class, lazily creating it if * necessary.<p> * * This method should only be called on the EDT. * * @return The singleton instance of this class. */ public static ClipboardHistory get() { if (instance==null) { instance = new ClipboardHistory(); } return instance; }
/** * Inserts the selected item into the editor and disposes of this popup. */ private void insertSelectedItem() { Object lvp = list.getSelectedValue(); if (lvp!=null) { listener.uninstallAndHide(); String text = ((LabelValuePair)lvp).value; textArea.replaceSelection(text); ClipboardHistory.get().add(text); // Move this item to the top } }
public ClipboardHistoryAction() { super(clipboardHistoryAction); clipboardHistory = ClipboardHistory.get(); }
/** * Sets the maximum number of clipboard values remembered. * * @param maxSize The maximum number of clipboard values to remember. * @throws IllegalArgumentException If <code>maxSize</code> is not greater * than zero. * @see #getMaxSize() */ public void setMaxSize(int maxSize) { if (maxSize<=0) { throw new IllegalArgumentException("Maximum size must be >= 0"); } this.maxSize = maxSize; trim(); }
/** * This method is called after data has been exported. This method should * remove the data that was transfered if the action was MOVE. * * @param source The component that was the source of the data. * @param data The data that was transferred or possibly null * if the action is <code>NONE</code>. * @param action The actual action that was performed. */ @Override protected void exportDone(JComponent source, Transferable data, int action) { // only remove the text if shouldRemove has not been set to // false by importData and only if the action is a move if (shouldRemove && action == MOVE) { TextTransferable t = (TextTransferable)data; t.removeText(); if (withinSameComponent) { ((RTextArea)source).endAtomicEdit(); withinSameComponent = false; } } exportComp = null; if (data instanceof TextTransferable) { ClipboardHistory.get().add(((TextTransferable)data).getPlainData()); } }
/** * Adds an entry to the clipboard history. * * @param str The text to add. * @see #getHistory() */ public void add(String str) { int size = history.size(); if (size==0) { history.add(str); } else { int index = history.indexOf(str); if (index!=size-1) { if (index>-1) { history.remove(index); } history.add(str); } trim(); } }