/** * 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. Added in fifo fashion. */ public void add(IEditorInput input, IEditorDescriptor desc) { if (input != null && input.exists()) { add(new EditorHistoryItem(input, desc), 0); } }
/** * Reopens the editor for the given history item. */ private void open(EditorHistoryItem item) { IWorkbenchPage page = window.getActivePage(); if (page != null) { try { String itemName = item.getName(); if (!item.isRestored()) { item.restoreState(); } IEditorInput input = item.getInput(); IEditorDescriptor desc = item.getDescriptor(); if (input == null || !input.exists() || desc == null) { String title = WorkbenchMessages.OpenRecent_errorTitle; String msg = NLS.bind(WorkbenchMessages.OpenRecent_unableToOpen, itemName ); MessageDialog.openWarning(window.getShell(), title, msg); history.remove(item); } else { page.openEditor(input, desc.getId()); } } catch (PartInitException e2) { String title = WorkbenchMessages.OpenRecent_errorTitle; MessageDialog.openWarning(window.getShell(), title, e2 .getMessage()); history.remove(item); } } }