use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesController method setDefaultEngineIcons.
private void setDefaultEngineIcons(List<EngineCategoryDTO> engineCategoryDTOS) {
try {
StringBuilder cssBuilder = new StringBuilder();
for (EngineCategoryDTO category : engineCategoryDTOS) {
cssBuilder.append("#" + category.getName().toLowerCase() + "Button{\n");
URI categoryIcon = category.getIcon();
if (categoryIcon == null) {
cssBuilder.append("-fx-background-image: url('/org/phoenicis/javafx/views/common/phoenicis.png');\n");
} else {
cssBuilder.append("-fx-background-image: url('" + categoryIcon + "');\n");
}
cssBuilder.append("}\n");
}
String css = cssBuilder.toString();
Path temp = Files.createTempFile("defaultEngineIcons", ".css").toAbsolutePath();
File tempFile = temp.toFile();
tempFile.deleteOnExit();
Files.write(temp, css.getBytes());
String defaultEngineIconsCss = temp.toUri().toString();
themeManager.setDefaultEngineIconsCss(defaultEngineIconsCss);
} catch (IOException e) {
LOGGER.warn("Could not set default engine icons.", e);
}
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PhoenicisOrg.
the class EnginesSource method fetchAvailableEngines.
public void fetchAvailableEngines(List<CategoryDTO> categoryDTOS, Consumer<List<EngineCategoryDTO>> callback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
StringBuilder includesBuilder = new StringBuilder();
StringBuilder constructorsBuilder = new StringBuilder();
constructorsBuilder.append("function fetchEngines() {\n");
constructorsBuilder.append("var engines = [];\n");
for (CategoryDTO categoryDTO : categoryDTOS) {
final String engineName = categoryDTO.getName();
includesBuilder.append("include([\"Engines\", \"" + engineName + "\", \"Engine\", \"Object\"]);\n");
constructorsBuilder.append("engines[\"" + engineName + "\"] = new " + engineName + "().getAvailableVersions();\n");
}
constructorsBuilder.append("return engines;\n");
constructorsBuilder.append("}\n");
constructorsBuilder.append("fetchEngines();");
interactiveScriptSession.eval(includesBuilder.toString(), ignored -> interactiveScriptSession.eval(constructorsBuilder.toString(), output -> {
List<EngineCategoryDTO> engines = new ArrayList<>();
for (Map.Entry<String, Object> entry : ((Map<String, Object>) output).entrySet()) {
final EngineCategoryDTO engineCategoryDTO = new EngineCategoryDTO.Builder().withName(entry.getKey()).withDescription(entry.getKey()).withSubCategories(unSerialize(entry.getValue())).build();
engines.add(engineCategoryDTO);
}
callback.accept(engines);
}, this::throwError), this::throwError);
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EngineSubCategoryPanelSkin method createFilteredEngineVersions.
/**
* Creates a {@link FilteredList} object of the engine versions by applying the {@link EnginesFilter} known to the
* control
*
* @return A filtered list of the engine versions
*/
private ObservableList<EngineVersionDTO> createFilteredEngineVersions() {
final EnginesFilter filter = getControl().getFilter();
final EngineCategoryDTO engineCategory = getControl().getEngineCategory();
final EngineSubCategoryDTO engineSubCategory = getControl().getEngineSubCategory();
final FilteredList<EngineVersionDTO> filteredEngineVersions = FXCollections.observableArrayList(engineSubCategory.getPackages()).sorted(EngineSubCategoryDTO.comparator().reversed()).filtered(filter.createFilter(engineCategory, engineSubCategory));
filteredEngineVersions.predicateProperty().bind(Bindings.createObjectBinding(() -> filter.createFilter(engineCategory, engineSubCategory), filter.searchTermProperty(), filter.selectedEngineCategoryProperty(), filter.showInstalledProperty(), filter.showNotInstalledProperty()));
return filteredEngineVersions;
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesView method updateVersions.
/**
* updates available versions for a certain engine
*
* @param engineCategoryDTO engine
* @param versions available versions for the engine
*/
public void updateVersions(EngineCategoryDTO engineCategoryDTO, List<EngineSubCategoryDTO> versions) {
Platform.runLater(() -> {
EngineCategoryDTO newEngineCategoryDTO = new EngineCategoryDTO.Builder(engineCategoryDTO).withSubCategories(versions).build();
this.engineCategories.remove(engineCategoryDTO);
this.engineCategories.add(newEngineCategoryDTO);
});
}
use of org.phoenicis.engines.dto.EngineCategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesView method createEngineSubCategoryTabs.
private ObservableList<Tab> createEngineSubCategoryTabs(EngineSidebar sidebar) {
// initialize the engines sub category panels
final MappedList<List<EngineSubCategoryPanel>, EngineCategoryDTO> engineSubCategoryPanelGroups = new MappedList<>(this.engineCategories, engineCategory -> engineCategory.getSubCategories().stream().map(engineSubCategory -> {
final EngineSubCategoryPanel engineSubCategoryPanel = new EngineSubCategoryPanel();
engineSubCategoryPanel.setEngineCategory(engineCategory);
engineSubCategoryPanel.setEngineSubCategory(engineSubCategory);
engineSubCategoryPanel.setEnginesPath(this.enginesPath);
engineSubCategoryPanel.setFilter(this.filter);
engineSubCategoryPanel.setEngine(this.engines.get(engineCategory.getName().toLowerCase()));
engineSubCategoryPanel.selectedListWidgetProperty().bind(sidebar.selectedListWidgetProperty());
engineSubCategoryPanel.setOnEngineSelect(this::showEngineDetails);
return engineSubCategoryPanel;
}).collect(Collectors.toList()));
final ConcatenatedList<EngineSubCategoryPanel> engineSubCategoryPanels = ConcatenatedList.create(engineSubCategoryPanelGroups);
final FilteredList<EngineSubCategoryPanel> filteredEngineSubCategoryPanels = engineSubCategoryPanels.sorted(Comparator.comparing(engineSubCategoryPanel -> engineSubCategoryPanel.getEngineSubCategory().getName())).filtered(this.filter::filter);
filteredEngineSubCategoryPanels.predicateProperty().bind(Bindings.createObjectBinding(() -> this.filter::filter, this.filter.searchTermProperty(), this.filter.showInstalledProperty(), this.filter.showNotInstalledProperty()));
// map the panels to tabs
return new MappedList<>(filteredEngineSubCategoryPanels, engineSubCategoryPanel -> new Tab(engineSubCategoryPanel.getEngineSubCategory().getDescription(), engineSubCategoryPanel));
}
Aggregations