use of org.omegat.core.data.IProject.FileInfo in project omegat by omegat-org.
the class ProjectFilesListController method createContextMenuForRow.
private JPopupMenu createContextMenuForRow(int row) {
int[] rows;
if (IntStream.of(list.tableFiles.getSelectedRows()).anyMatch(r -> r == row)) {
// If clicked on selection, use selection
rows = list.tableFiles.getSelectedRows();
} else {
// Otherwise use the clicked row
rows = new int[] { row };
}
List<FileInfo> infos = IntStream.of(rows).map(list.tableFiles.getRowSorter()::convertRowIndexToModel).mapToObj(modelFiles::getDataAtRow).collect(Collectors.toList());
if (infos.isEmpty() || infos.stream().anyMatch(Objects::isNull)) {
return null;
}
String sourceDir = Core.getProject().getProjectProperties().getSourceRoot();
String targetDir = Core.getProject().getProjectProperties().getTargetRoot();
JPopupMenu menu = new JPopupMenu();
addContextMenuItem(menu, true, infos.stream().map(i -> new File(sourceDir, i.filePath)).collect(Collectors.toList()));
addContextMenuItem(menu, false, infos.stream().map(i -> new File(targetDir, Core.getProject().getTargetPathForSourceFile(i.filePath))).collect(Collectors.toList()));
return menu;
}
Aggregations