use of org.phoenicis.repository.dto.CategoryDTO in project phoenicis by PhoenicisOrg.
the class EnginesController method setDefaultEngineIcons.
private void setDefaultEngineIcons(List<CategoryDTO> categoryDTOS) {
try {
StringBuilder cssBuilder = new StringBuilder();
for (CategoryDTO category : categoryDTOS) {
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.repository.dto.CategoryDTO in project phoenicis 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.repository.dto.CategoryDTO in project phoenicis by PhoenicisOrg.
the class EngineToolsManager method fetchAvailableEngineTools.
/**
* fetches the available engine tools
* @param repositoryDTO
* @param callback
*/
public void fetchAvailableEngineTools(RepositoryDTO repositoryDTO, Consumer<Map<String, ApplicationDTO>> callback) {
Map<String, ApplicationDTO> tools = new HashMap<>();
// get engine CategoryDTOs
List<CategoryDTO> categoryDTOS = new ArrayList<>();
for (TypeDTO typeDTO : repositoryDTO.getTypes()) {
if (typeDTO.getId().equals("Engines")) {
categoryDTOS = typeDTO.getCategories();
}
}
for (CategoryDTO engine : categoryDTOS) {
for (ApplicationDTO applicationDTO : engine.getApplications()) {
if (applicationDTO.getId().equals("Tools")) {
tools.put(engine.getId(), applicationDTO);
}
}
}
callback.accept(tools);
}
use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PlayOnLinux.
the class AppsController method setDefaultCategoryIcons.
/**
* sets the default category icons from the repository for the sidebar buttons
*
* @param categories categories in repository
*/
private void setDefaultCategoryIcons(List<CategoryDTO> categories) {
Platform.runLater(() -> {
try {
StringBuilder cssBuilder = new StringBuilder();
for (CategoryDTO category : categories) {
cssBuilder.append("#" + ApplicationSidebarToggleGroupSkin.getToggleButtonId(category.getId()) + "{\n");
final String categoryIconPath = Optional.ofNullable(category.getIcon()).map(categoryIcon -> categoryIcon.toString()).orElse("/org/phoenicis/javafx/views/common/phoenicis.png");
cssBuilder.append(String.format("-fx-background-image: url('%s');\n", categoryIconPath));
cssBuilder.append("}\n");
}
String css = cssBuilder.toString();
Path temp = Files.createTempFile("defaultCategoryIcons", ".css").toAbsolutePath();
File tempFile = temp.toFile();
tempFile.deleteOnExit();
Files.write(temp, css.getBytes());
String defaultCategoryIconsCss = temp.toUri().toString();
this.themeManager.setDefaultCategoryIconsCss(defaultCategoryIconsCss);
} catch (IOException e) {
LOGGER.warn("Could not set default category icons.", e);
}
});
}
use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PlayOnLinux.
the class EnginesController method setDefaultEngineIcons.
/**
* Generates css for the button design associated with the given categories
*
* @param categoryDTOS The categories
*/
private void setDefaultEngineIcons(List<CategoryDTO> categoryDTOS) {
try {
StringBuilder cssBuilder = new StringBuilder();
for (CategoryDTO category : categoryDTOS) {
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);
}
}
Aggregations