use of eu.esdihumboldt.hale.ui.templates.webtemplates.WebTemplate in project hale by halestudio.
the class OpenWebTemplate method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final Display display = HandlerUtil.getActiveShell(event).getDisplay();
ProgressMonitorDialog taskDlg = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));
try {
taskDlg.run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Downloading template list", IProgressMonitor.UNKNOWN);
// load templates
final List<WebTemplate> templates;
try {
templates = WebTemplateLoader.load();
} catch (Exception e) {
log.userError("Failed to download template list", e);
return;
} finally {
monitor.done();
}
if (templates != null) {
// launch dialog asynchronously in display thread
display.asyncExec(new Runnable() {
@Override
public void run() {
WebTemplatesDialog dlg = new WebTemplatesDialog(display.getActiveShell(), templates);
if (dlg.open() == WebTemplatesDialog.OK) {
WebTemplate template = dlg.getObject();
if (template != null) {
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
ps.load(template.getProject());
}
}
}
});
}
}
});
} catch (InvocationTargetException | InterruptedException e) {
log.userError("Failed to download template list", e);
}
return null;
}
Aggregations