private IStatus computeAllRemediations(IProgressMonitor monitor) { SubMonitor sub = SubMonitor.convert(monitor, remedyConfigs.length); sub.setTaskName(Messages.RemediationOperation_ProfileChangeRequestProgress); List<Remedy> tmpRemedies = new ArrayList<Remedy>(remedyConfigs.length); try { for (int i = 0; i < remedyConfigs.length; i++) { sub.subTask((i + 1) + " / " + remedyConfigs.length); // $NON-NLS-1$ if (sub.isCanceled()) return Status.CANCEL_STATUS; Remedy remedy = computeRemedy(remedyConfigs[i], sub.newChild(1, SubMonitor.SUPPRESS_ALL_LABELS)); if (remedy != null) { tmpRemedies.add(remedy); } } } finally { sub.done(); } remedies = tmpRemedies; return getResolutionResult(); }
@Override public Map<ModuleNeeded, File> getFilesToShare(IProgressMonitor monitor) { Map<ModuleNeeded, File> files = new HashMap<ModuleNeeded, File>(); SubMonitor mainSubMonitor = SubMonitor.convert(monitor, 1); mainSubMonitor.setTaskName(Messages.getString("ShareLibsJob.getFilesToShare")); // $NON-NLS-1$ final List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>(ModulesNeededProvider.getModulesNeeded()); ILibraryManagerService librariesService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class); Set<String> filePaths = new HashSet<String>(); for (ModuleNeeded module : modulesNeeded) { if (monitor.isCanceled()) { return null; } // only deploy libraries with group id org.talend.libraries MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(module.getMavenUri()); if (parseMvnUrl == null || !MavenConstants.DEFAULT_LIB_GROUP_ID.equals(parseMvnUrl.getGroupId())) { continue; } final String jarPathFromMaven = librariesService.getJarPathFromMaven(module.getMavenUriSnapshot()); if (jarPathFromMaven == null) { continue; } File jarFile = new File(jarPathFromMaven); if (jarFile.exists()) { if (!filePaths.contains(jarPathFromMaven)) { files.put(module, jarFile); } filePaths.add(jarPathFromMaven); } } mainSubMonitor.worked(1); return files; }
@Override public void run(IProgressMonitor progress) throws InvocationTargetException { SubMonitor monitor = SubMonitor.convert(progress, 3); monitor.setTaskName("Loading Templates..."); try { final Set<Template> templates = new LinkedHashSet<>(); final List<String> errors = new LinkedList<>(); // Load from workspace, if one exists Workspace ws = Central.getWorkspaceIfPresent(); if (ws != null) { List<Repository> repos = ws.getPlugins(Repository.class); RepoPluginsBundleLocator locator = new RepoPluginsBundleLocator(ws.getRepositories()); templates.addAll( new ReposTemplateLoader(repos, locator) .findTemplates( templateType, errors, monitor.newChild(1, SubMonitor.SUPPRESS_NONE))); } // Load from the preferences-configured template repository BndPreferences bndPrefs = new BndPreferences(); if (bndPrefs.getEnableTemplateRepo()) { try { FixedIndexedRepo repo = loadRepo(bndPrefs.getTemplateRepoUriList()); RepoPluginsBundleLocator locator = new RepoPluginsBundleLocator(Collections.<RepositoryPlugin>singletonList(repo)); ReposTemplateLoader loader = new ReposTemplateLoader(Collections.<Repository>singletonList(repo), locator); templates.addAll( loader.findTemplates( templateType, errors, monitor.newChild(1, SubMonitor.SUPPRESS_NONE))); } catch (Exception e) { throw new InvocationTargetException(e); } } // Log errors for (String error : errors) { Plugin.getDefault() .getLog() .log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, error, null)); } // Add the build-in empty template if provided if (emptyTemplate != null) templates.add(emptyTemplate); // Load from extension registry if (templateExtPoint != null) { IConfigurationElement[] elements = Platform.getExtensionRegistry() .getConfigurationElementsFor(Plugin.PLUGIN_ID, templateExtPoint); if (elements == null) elements = new IConfigurationElement[0]; monitor.setWorkRemaining(elements.length); for (IConfigurationElement element : elements) { String elementName = element.getName(); IContributor contributor = element.getContributor(); try { Template extTemplate = (Template) element.createExecutableExtension("class"); templates.add(extTemplate); } catch (CoreException e) { Plugin.getDefault() .getLog() .log( new Status( IStatus.ERROR, Plugin.PLUGIN_ID, 0, String.format( "Error loading template '%s' from bundle %s", elementName, contributor.getName()), e)); } finally { monitor.worked(1); } } } // Display results Control control = viewer.getControl(); if (control != null && !control.isDisposed()) { control .getDisplay() .asyncExec( new Runnable() { @Override public void run() { setTemplates(templates); IconLoaderJob iconLoaderJob = new IconLoaderJob(templates, viewer, loadedImages, 5); iconLoaderJob.setSystem(true); iconLoaderJob.schedule(0); } }); } } finally { monitor.done(); // Restore the original message to the page if (!shell.isDisposed()) shell .getDisplay() .asyncExec( new Runnable() { @Override public void run() { setMessage(originalMessage); } }); } }