Java 类org.eclipse.ui.IElementFactory 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:Mementos.java   
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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Mementos.java   
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);
}
项目:skin4eclipse    文件:EditorInfo.java   
/**
 * Restores the object state from the memento.
 */
private void restoreState(IMemento memento) {
    if (memento == null) {
        return;
    }

    String factoryId = memento.getString("factoryID");
    if (factoryId == null) {
        PresentationPlugin.log("Couldn't restore editor info from memento: "
                + memento.getID() + ", 'factoryID' is null", null);
        return;
    }
    IMemento persistableMemento = memento.getChild("persistable");
    if (persistableMemento == null) {
        PresentationPlugin.log("Couldn't restore editor info from memento: "
                + memento.getID() + ", 'persistable' element is null", null);
        return;
    }
    IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryId);
    if (factory == null) {
        // try to use default file factory, it would work if the memento contains a path to file
        String path = persistableMemento.getString("path");
        if (path == null) {
            PresentationPlugin.log("Couldn't find factory for id: "
                    + factoryId + ", I give up now...", null);
            return;
        }
        factory = PlatformUI.getWorkbench().getElementFactory(
                FileEditorInputFactory.getFactoryId());
        PresentationPlugin.log("Couldn't find factory for id: "
                + factoryId + ", will try to use default file factory", null);
    }
    IAdaptable adaptable = factory.createElement(persistableMemento);
    if (adaptable == null || (adaptable instanceof IEditorInput) == false) {
        return;
    }
    input = (IEditorInput) adaptable;
    editorId = memento.getString("id");
    Integer intNumber = memento.getInteger("number");
    number = intNumber == null? 0 : intNumber.intValue();
}