下面列出了怎么用org.eclipse.ui.IElementFactory的API类实例代码及写法,或者点击链接到github查看源代码。
private IEditorInput getRestoredInput(IEditorReference e) {
IMemento editorMem = null;
if (CheckstyleUIPlugin.isE3()) {
editorMem = getMementoE3(e);
} else {
editorMem = getMementoE4(e);
}
if (editorMem == null) {
return null;
}
IMemento inputMem = editorMem.getChild(IWorkbenchConstants.TAG_INPUT);
String factoryID = null;
if (inputMem != null) {
factoryID = inputMem.getString(IWorkbenchConstants.TAG_FACTORY_ID);
}
if (factoryID == null) {
return null;
}
IAdaptable input = null;
IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID);
if (factory == null) {
return null;
}
input = factory.createElement(inputMem);
if (input == null) {
return null;
}
if (!(input instanceof IEditorInput)) {
return null;
}
return (IEditorInput) input;
}
public static IAdaptable restoreItem(IMemento memento, String factoryTag) {
if (memento == null)
return null;
String factoryID = memento.getString(factoryTag);
if (factoryID == null) return null;
IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID);
if (factory == null) return null;
return factory.createElement(memento);
}