use of org.eclipse.core.resources.mapping.ResourceMapping in project egit by eclipse.
the class RepositoryActionHandler method extractProjectsFromMappings.
private Set<IProject> extractProjectsFromMappings(IStructuredSelection selection) {
Set<IProject> ret = new LinkedHashSet<>();
for (ResourceMapping mapping : getSelectedAdaptables(selection, ResourceMapping.class)) {
IProject[] mappedProjects = mapping.getProjects();
if (mappedProjects != null && mappedProjects.length != 0) {
// Some mappings (WorkingSetResourceMapping) return the projects
// in unpredictable order. Sort them like the navigator to
// correspond to the order the user usually sees.
List<IProject> projects = new ArrayList<>(Arrays.asList(mappedProjects));
Collections.sort(projects, CommonUtils.RESOURCE_NAME_COMPARATOR);
ret.addAll(projects);
}
}
return ret;
}
use of org.eclipse.core.resources.mapping.ResourceMapping in project egit by eclipse.
the class SelectionUtils method getSelectionContents.
/**
* Determines a set of either {@link Repository}, {@link IResource}s or
* {@link IPath}s from a selection. For selection contents that adapt to
* {@link Repository}, {@link IResource} or {@link ResourceMapping}, the
* containing {@link Repository}s or {@link IResource}s are included in the
* result set; otherwise for selection contents that adapt to {@link IPath}
* these paths are included.
*
* @param selection
* to process
* @return the set of {@link Repository}, {@link IResource} and
* {@link IPath} objects from the selection; not containing
* {@code null} values
*/
@NonNull
private static Set<Object> getSelectionContents(@NonNull IStructuredSelection selection) {
Set<Object> result = new HashSet<>();
for (Object o : selection.toList()) {
Repository r = AdapterUtils.adapt(o, Repository.class);
if (r != null) {
result.add(r);
continue;
}
IResource resource = AdapterUtils.adaptToAnyResource(o);
if (resource != null) {
result.add(resource);
continue;
}
ResourceMapping mapping = AdapterUtils.adapt(o, ResourceMapping.class);
if (mapping != null) {
result.addAll(extractResourcesFromMapping(mapping));
} else {
IPath location = AdapterUtils.adapt(o, IPath.class);
if (location != null) {
result.add(location);
}
}
}
return result;
}
use of org.eclipse.core.resources.mapping.ResourceMapping in project dbeaver by serge-rider.
the class GITAbstractHandler method extractProjectsFromMappings.
private static Set<IProject> extractProjectsFromMappings(IStructuredSelection selection) {
Set<IProject> ret = new LinkedHashSet<>();
for (ResourceMapping mapping : getSelectedAdaptables(selection, ResourceMapping.class)) {
IProject[] mappedProjects = mapping.getProjects();
if (mappedProjects != null && mappedProjects.length != 0) {
// Some mappings (WorkingSetResourceMapping) return the projects
// in unpredictable order. Sort them like the navigator to
// correspond to the order the user usually sees.
List<IProject> projects = new ArrayList<>(Arrays.asList(mappedProjects));
projects.sort(CommonUtils.RESOURCE_NAME_COMPARATOR);
ret.addAll(projects);
}
}
return ret;
}
Aggregations