org.eclipse.ui.IElementFactory Java Examples

The following examples show how to use org.eclipse.ui.IElementFactory. 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: CheckFileOnOpenPartListener.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
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;
  }
 
Example #2
Source File: Mementos.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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);
}