use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.
the class _7zSoftProvider method getSoftLocator.
/**
* @see org.fagu.fmv.soft.find.SoftProvider#getSoftLocator()
*/
@Override
public SoftLocator getSoftLocator() {
SoftLocator softLocator = super.getSoftLocator();
if (SystemUtils.IS_OS_WINDOWS) {
ProgramFilesLocatorSupplier.with(softLocator).findFolder("7-Zip").supplyIn();
softLocator.addDefaultLocator();
}
return softLocator;
}
use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.
the class JavaSoftProvider method getSoftLocator.
/**
* @see org.fagu.fmv.soft.find.SoftProvider#getSoftLocator()
*/
@Override
public SoftLocator getSoftLocator() {
SoftLocator softLocator = new SoftLocator(getName()) {
/**
* @see org.fagu.fmv.soft.find.SoftLocator#getLocators(java.lang.String, org.fagu.fmv.soft.find.Locators,
* java.io.FileFilter)
*/
@Override
protected List<Locator> getLocators(Locators loc) {
List<Locator> list = super.getLocators(loc);
Locators locators = createLocators();
list.add(0, locators.byPropertyPath("java.home"));
if (SystemUtils.IS_OS_WINDOWS) {
ProgramFilesLocatorSupplier.with(list::add, locators).find(programFile -> {
List<File> files = new ArrayList<>();
File[] javaFolders = programFile.listFiles(f -> "java".equalsIgnoreCase(f.getName()));
if (javaFolders != null) {
for (File folder : javaFolders) {
File[] subFolders = folder.listFiles();
if (subFolders != null) {
for (File subFolder : subFolders) {
files.add(subFolder);
files.add(new File(subFolder, "bin"));
}
}
}
}
return files;
}).supplyIn();
}
return list;
}
};
softLocator.setSoftPolicy(getSoftPolicy());
softLocator.setEnvName("JAVA_HOME");
return softLocator;
}
use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.
the class PdfSoftProvider method getSoftLocator.
/**
* @see org.fagu.fmv.soft.find.SoftProvider#getSoftLocator()
*/
@Override
public SoftLocator getSoftLocator() {
SoftLocator softLocator = super.getSoftLocator();
if (SystemUtils.IS_OS_WINDOWS) {
ProgramFilesLocatorSupplier.with(softLocator).find(programFile -> {
File[] listFiles = programFile.listFiles(f -> f.getName().startsWith("xpdf"));
if (listFiles == null || listFiles.length == 0) {
return Collections.emptyList();
}
String arch = "bin" + System.getProperty("sun.arch.data.model");
return Arrays.asList(listFiles).stream().map(f -> new File(f, arch)).collect(Collectors.toList());
}).supplyIn();
softLocator.addDefaultLocator();
}
return softLocator;
}
use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.
the class SoftSearch method search.
/**
* @return
*/
public Soft search() {
SoftLocator locator = getLocator();
Founds founds = locator.find();
return createAndfireEventFound(founds, locator);
}
use of org.fagu.fmv.soft.find.SoftLocator in project fmv by f-agu.
the class SoftSearch method search.
/**
* @param softFoundFactory
* @return
*/
public Soft search(SoftFoundFactory softFoundFactory) {
checkUsed();
SoftLocator locator = getLocator();
Founds founds = locator.find((file, loc, softPol) -> {
try {
SoftFound softFound = softFoundFactory.create(file, loc, softPol);
if (softFound == null) {
return SoftFound.foundBadSoft(file);
}
return softFound;
} catch (IOException e) {
return SoftFound.foundError(file, e.getMessage()).setLocalizedBy(locator.toString());
}
});
return createAndfireEventFound(founds, locator);
}
Aggregations