use of org.eclipse.ui.IElementFactory in project yamcs-studio by yamcs.
the class OPIView method init.
@Override
public void init(final IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
this.site = site;
if (debug)
System.out.println(site.getId() + ":" + site.getSecondaryId() + " opened " + (memento == null ? ", no memento" : "with memento"));
if (memento == null) {
memento = findMementoFromPlaceholder();
}
if (memento == null) {
return;
}
// Load previously displayed input from memento
final String factoryID = memento.getString(TAG_FACTORY_ID);
if (factoryID == null) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, toString() + " has memento with empty factory ID");
return;
}
final IMemento inputMem = memento.getChild(TAG_INPUT);
final IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID);
if (factory == null)
throw new PartInitException(NLS.bind("Cannot instantiate input element factory {0} for OPIView", factoryID));
final IAdaptable element = factory.createElement(inputMem);
if (!(element instanceof IEditorInput))
throw new PartInitException("Instead of IEditorInput, " + factoryID + " returned " + element);
// Set input, but don't persist to memento because we just read it from memento
setOPIInput((IEditorInput) element, false);
}
Aggregations