use of org.eclipse.ui.IEditorSite in project bndtools by bndtools.
the class BndEditor method init.
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
try {
// Work out our input file and subscribe to resource changes
this.inputResource = ResourceUtil.getResource(input);
inputResource.getWorkspace().addResourceChangeListener(this);
inputFile = inputResource.getLocation().toFile();
model.setBndResourceName(inputResource.getName());
// Initialize pages and title
initPages(site, input);
setSourcePage(sourcePage);
setPartNameForInput(input);
IDocumentProvider docProvider = sourcePage.getDocumentProvider();
// #1625: Ensure the IDocumentProvider is not null.
if (docProvider != null) {
docProvider.addElementStateListener(new ElementStateListener());
if (!Central.hasWorkspaceDirectory()) {
// default ws will be created we can load immediately
modelReady = loadEditModel();
} else {
// a real ws will be resolved so we need to load async
modelReady = Central.onWorkspace(workspace -> loadEditModel());
}
} else {
modelReady = Central.promiseFactory().failed(new Exception("Model unavailable"));
}
setupActions();
} catch (Exception e1) {
throw Exceptions.duck(e1);
}
}
Aggregations