List<MavenId> () { TreePath[] selectionPaths = myResultList.getSelectionPaths(); if (selectionPaths == null) { return Collections.emptyList(); } List<MavenId> result = new ArrayList<>(); for (TreePath each : selectionPaths) { Object sel = each.getLastPathComponent(); MavenDependencyCompletionItem info; if (sel instanceof MavenDependencyCompletionItem) { info = (MavenDependencyCompletionItem)sel; } else { info = ((MavenArtifactSearchResult)sel).getSearchResults().getItems()[0]; } result.add(new MavenId(info.getGroupId(), info.getArtifactId(), info.getVersion())); } return result; }