public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { OPCGendocActivator activator = OPCGendocActivator.getDefault(); IGendocDiagnostician diagnostician = GendocServices.getDefault().getService(IGendocDiagnostician.class); diagnostician.init(); IProgressMonitorService monitorService = (IProgressMonitorService) GendocServices.getDefault().getService(IProgressMonitorService.class); monitorService.setMonitor(monitor); try { GendocProcess gendocProcess = new GendocProcess(); EMFModelLoaderService service = new EMFModelLoaderService() { @Override public EObject getModel(URI path) throws ModelNotFoundException { return source; } }; service.setServiceId("IEMFModelLoaderService"); GendocServices.getDefault().setService(IEMFModelLoaderService.class, service); IConfigurationService conf = GendocServices.getDefault().getService(IConfigurationService.class); conf.setOutput(getOutpuPath()); URL templateUrl = gd.getTemplateURL(); String resultFile = gendocProcess.runProcess(templateUrl); handleDiagnostic( diagnostician.getResultDiagnostic(), "The file has been generated but contains errors :\n", resultFile); } catch (GenDocException e) { activator .getLog() .log(new Status(IStatus.ERROR, OPCGendocActivator.PLUGIN_ID, e.getUIMessage(), e)); diagnostician.addDiagnostic( new BasicDiagnostic( Diagnostic.ERROR, OPCGendocActivator.PLUGIN_ID, 0, e.getUIMessage(), null)); handleDiagnostic( diagnostician.getResultDiagnostic(), "An error occured during generation.", null); } catch (Throwable t) { activator .getLog() .log(new Status(IStatus.ERROR, OPCGendocActivator.PLUGIN_ID, t.getMessage(), t)); diagnostician.addDiagnostic( new BasicDiagnostic( Diagnostic.ERROR, OPCGendocActivator.PLUGIN_ID, 0, t.getMessage(), t.getStackTrace())); handleDiagnostic( diagnostician.getResultDiagnostic(), "An unexpected error occured during the generation.", null); } finally { GendocServices.getDefault().clear(); } }