/** @see ReportHandler#publishReport(Report) */ @Override public void publishReport(Report<?> report) { ReportService repService = (ReportService) PlatformUI.getWorkbench().getService(ReportService.class); repService.addReport(report); }
/** * @see Wizard#performFinish() * @return <code>true</code> if executing the I/O provider was successful */ @Override public boolean performFinish() { if (getProvider() == null) { return false; } if (!applyConfiguration()) { return false; } // create default report IOReporter defReport = provider.createReporter(); // validate and execute provider try { // validate configuration provider.validate(); ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class); URI projectLoc = ps.getLoadLocation() == null ? null : ps.getLoadLocation(); boolean isProjectResource = false; if (actionId != null) { // XXX instead move project resource to action? ActionUI factory = ActionUIExtension.getInstance().findActionUI(actionId); isProjectResource = factory.isProjectResource(); } // prevent loading of duplicate resources if (isProjectResource && provider instanceof ImportProvider) { String currentResource = ((ImportProvider) provider).getSource().getLocation().toString(); URI currentAbsolute = URI.create(currentResource); if (projectLoc != null && !currentAbsolute.isAbsolute()) currentAbsolute = projectLoc.resolve(currentAbsolute); for (IOConfiguration conf : ((Project) ps.getProjectInfo()).getResources()) { Value otherResourceValue = conf.getProviderConfiguration().get(ImportProvider.PARAM_SOURCE); if (otherResourceValue == null) continue; String otherResource = otherResourceValue.as(String.class); URI otherAbsolute = URI.create(otherResource); if (projectLoc != null && !otherAbsolute.isAbsolute()) otherAbsolute = projectLoc.resolve(otherAbsolute); String action = conf.getActionId(); // resource is already loaded into the project if (currentAbsolute.equals(otherAbsolute) && Objects.equal(actionId, action)) { log.userError("Resource is already loaded. Loading duplicate resources is aborted!"); return false; } } } // enable provider internal caching if (isProjectResource && provider instanceof CachingImportProvider) { ((CachingImportProvider) provider).setProvideCache(); } IOReport report = execute(provider, defReport); if (report != null) { // add report to report server ReportService repService = PlatformUI.getWorkbench().getService(ReportService.class); repService.addReport(report); // show message to user if (report.isSuccess()) { // no message, we rely on the report being shown/processed // let advisor handle results try { getContainer() .run( true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Completing operation...", IProgressMonitor.UNKNOWN); try { advisor.handleResults(getProvider()); } finally { monitor.done(); } } }); } catch (InvocationTargetException e) { log.userError( "Error processing results:\n" + e.getCause().getLocalizedMessage(), e.getCause()); return false; } catch (Exception e) { log.userError("Error processing results:\n" + e.getLocalizedMessage(), e); return false; } // add to project service if necessary if (isProjectResource) ps.rememberIO(actionId, getProviderFactory().getIdentifier(), provider); return true; } else { // error message log.userError(report.getSummary() + "\nPlease see the report for details."); return false; } } else return true; } catch (IOProviderConfigurationException e) { // user feedback log.userError( "Validation of the provider configuration failed:\n" + e.getLocalizedMessage(), e); return false; } }