use of org.eclipse.m2e.core.ui.internal.util.ParentGatherer in project m2e-core by eclipse-m2e.
the class DependenciesComposite method openManageDependenciesDialog.
void openManageDependenciesDialog() throws InvocationTargetException, InterruptedException {
/*
* A linked list representing the path from child to root parent pom.
* The head is the child, the tail is the root pom
*/
final List<ParentHierarchyEntry> hierarchy = new ArrayList<>();
IRunnableWithProgress projectLoader = monitor -> {
try {
IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
IMavenProjectFacade projectFacade = projectManager.create(pomEditor.getPomFile(), true, monitor);
if (projectFacade != null) {
hierarchy.addAll(new ParentGatherer(projectFacade).getParentHierarchy(monitor));
}
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
};
PlatformUI.getWorkbench().getProgressService().run(false, true, projectLoader);
if (hierarchy.isEmpty()) {
// User has already been notified to fix the problem.
return;
}
final ManageDependenciesDialog manageDepDialog = new ManageDependenciesDialog(getShell(), new ValueProvider<List<org.apache.maven.model.Dependency>>() {
@Override
public List<org.apache.maven.model.Dependency> getValue() {
List<org.apache.maven.model.Dependency> toRet = new ArrayList<>();
for (DependenciesComposite.Dependency d : getDependencies()) {
toRet.add(toApacheDependency(d));
}
return toRet;
}
}, hierarchy, dependenciesEditor.getSelection());
manageDepDialog.open();
}
use of org.eclipse.m2e.core.ui.internal.util.ParentGatherer in project m2e-core-tests by tesla.
the class ExcludeArtifactRefactoringTest method createRefactoring.
private static ExcludeArtifactRefactoring createRefactoring(IFile pomFile, ArtifactKey[] keys, IFile exclusionPoint) throws CoreException {
ExcludeArtifactRefactoring refactoring = new ExcludeArtifactRefactoring(keys);
IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(pomFile, true, monitor);
ParentGatherer g = new ParentGatherer(facade);
List<ParentHierarchyEntry> hierarchy = g.getParentHierarchy(monitor);
refactoring.setHierarchy(hierarchy);
ParentHierarchyEntry exclusionModel = null;
for (ParentHierarchyEntry model : hierarchy) {
if (exclusionPoint.equals(model.getResource())) {
exclusionModel = model;
break;
}
}
if (exclusionModel == null) {
fail("Exclusion point is not present in project parent hierarchy");
}
refactoring.setExclusionPoint(exclusionModel);
return refactoring;
}
Aggregations