org.eclipse.ui.internal.EditorHistoryItem Java Examples

The following examples show how to use org.eclipse.ui.internal.EditorHistoryItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonFunction.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 当删除一个文件时,刷新历史记录	--robert	2012-11-20
 */
@SuppressWarnings("restriction")
public static void refreshHistoryWhenDelete(IEditorInput input){
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench instanceof Workbench) {
		EditorHistory history = ((Workbench) workbench).getEditorHistory();
		for (EditorHistoryItem item : history.getItems()) {
			if (item.matches(input)) {
				history.remove(item);
			}
		}
		history.refresh();
	}
}
 
Example #2
Source File: CommonFunction.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 当删除一个文件时,刷新历史记录	--robert	2012-11-20
 */
@SuppressWarnings("restriction")
public static void refreshHistoryWhenDelete(IEditorInput input){
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench instanceof Workbench) {
		EditorHistory history = ((Workbench) workbench).getEditorHistory();
		for (EditorHistoryItem item : history.getItems()) {
			if (item.matches(input)) {
				history.remove(item);
			}
		}
		history.refresh();
	}
}
 
Example #3
Source File: RecentFilesContentProvider.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createContent(Document dom, Element parent) {
    if (!RepositoryManager.getInstance().hasActiveRepository()
            || !RepositoryManager.getInstance().getCurrentRepository().isLoaded()) {
        return;
    }

    Element ul = dom.createElement("ul");
    parent.appendChild(ul);

    EditorHistory history = ((Workbench) PlatformUI.getWorkbench()).getEditorHistory();
    EditorHistoryItem[] historyItems = history.getItems();
    int maxElem = MAX_HISTORY_SIZE;
    for (int i = 0; i < historyItems.length; i++) {
        if (maxElem == 0)
            break;
        final EditorHistoryItem item = historyItems[i];
        if (item.isRestored() || item.restoreState().isOK()) {
            IEditorInput input = item.getInput();
            if(input == null) {
                break;
            }
            IResource resource = input.getAdapter(IResource.class);
            if (resource != null && resource.isAccessible()) {
                Element li = dom.createElement("li");
                Element a = dom.createElement("a");
                a.setAttribute("class", "hover:text-red-600");
                a.setAttribute("title", item.getToolTipText());
                try {
                    a.setAttribute("href",
                            String.format("http://org.eclipse.ui.intro/runAction?pluginId=%s&class=%s&file=%s",
                                    Activator.PLUGIN_ID,
                                    OpenEditorFromHistoryItemAction.class.getName(),
                                    URLEncoder.encode(item.getName(), "UTF-8")));
                } catch (DOMException | UnsupportedEncodingException e) {
                    BonitaStudioLog.error(e);
                }
                a.setTextContent(item.getName());
                li.appendChild(a);
                maxElem--;
                ul.appendChild(li);
            }
        }
    }
}
 
Example #4
Source File: OpenEditorFromHistoryItemAction.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private Optional<EditorHistoryItem> findItem(EditorHistory history, int n, String itemName) {
    return Stream.of(history.getItems())
            .limit(n)
            .filter(item -> Objects.equals(item.getName(), itemName))
            .findFirst();
}