use of org.fagu.fmv.soft.find.Founds in project fmv by f-agu.
the class SoftLogger method logDetails.
/**
* @param formatConsumer
*/
public SoftLogger logDetails(Consumer<String> formatConsumer) {
int maxLength = getNameMaxLength() + 3;
for (Soft soft : softs) {
Founds founds = soft.getFounds();
String name = soft.getName();
SoftFound firstFound = founds.getFirstFound();
SoftProvider softProvider = soft.getSoftProvider();
if (founds.isFound()) {
toLine(startLine(maxLength, name, firstFound), softProvider, firstFound, formatConsumer);
} else {
if (founds.isEmpty()) {
toLine(startLine(maxLength, name, firstFound), softProvider, SoftFound.notFound(), formatConsumer);
} else {
int index = 0;
for (SoftFound softFound : founds) {
toLine(startLine(maxLength, 0 == index++ ? name : null, softFound), softProvider, softFound, formatConsumer);
}
}
String downloadURL = softProvider.getDownloadURL();
if (downloadURL != null && !"".equals(downloadURL.trim())) {
formatConsumer.accept(" Download " + name + " at " + downloadURL + " and add the path in your system environment PATH");
}
}
}
return this;
}
use of org.fagu.fmv.soft.find.Founds 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.Founds 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);
}
use of org.fagu.fmv.soft.find.Founds in project fmv by f-agu.
the class SoftSearch method search.
/**
* @param softTester
* @return
*/
public Soft search(SoftTester softTester) {
checkUsed();
SoftLocator locator = getLocator();
Founds founds = locator.find(softTester);
return createAndfireEventFound(founds, locator);
}
use of org.fagu.fmv.soft.find.Founds in project fmv by f-agu.
the class Soft method withExecFile.
/**
* @param softName
* @return
*/
public static Soft withExecFile(File file) throws IOException {
if (!file.exists()) {
throw new FileNotFoundException(file.getAbsolutePath());
}
if (!file.isFile()) {
throw new IOException("It's not a file: " + file.getAbsolutePath());
}
Path path = file.toPath();
if (!Files.isExecutable(path)) {
throw new IOException("Cannot execute: " + file.getAbsolutePath());
}
SoftProvider softProvider = new SoftProvider(file.getName(), null) {
@Override
public SoftFoundFactory createSoftFoundFactory() {
throw new RuntimeException("Not available !");
}
};
TreeSet<SoftFound> founds = new TreeSet<>(Collections.singleton(SoftFound.found(file)));
return new Soft(new Founds(softProvider.getName(), founds, null), softProvider);
}
Aggregations