/** Refresh the editor list. Any stale items are removed. Only restored items are considered. */ public void refresh() { Iterator iter = fifoList.iterator(); while (iter.hasNext()) { EditorHistoryItem item = (EditorHistoryItem) iter.next(); if (item.isRestored()) { IEditorInput input = item.getInput(); if (input != null && !input.exists()) { iter.remove(); } } } }
/** Adds an item to the history. */ private void add(EditorHistoryItem newItem, int index) { // Remove the item if it already exists so that it will be put // at the top of the list. if (newItem.isRestored()) { remove(newItem.getInput()); } // Remove the oldest one if (fifoList.size() == MAX_SIZE) { fifoList.remove(MAX_SIZE - 1); } // Add the new item. fifoList.add(index < MAX_SIZE ? index : MAX_SIZE - 1, newItem); }