Search in sources :

Example 26 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PhoenicisOrg.

the class VerbsManager method fetchAvailableVerbs.

/**
 * Fetches the available Verbs
 *
 * @param repositoryDTO
 * @param callback
 */
public void fetchAvailableVerbs(RepositoryDTO repositoryDTO, Consumer<Map<String, ApplicationDTO>> callback) {
    Map<String, ApplicationDTO> verbs = 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(engine.getId() + ".verbs")) {
                verbs.put(engine.getId().replaceAll("^.*\\.", ""), applicationDTO);
            }
        }
    }
    callback.accept(verbs);
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeDTO(org.phoenicis.repository.dto.TypeDTO)

Example 27 with CategoryDTO

use of org.phoenicis.repository.dto.CategoryDTO in project POL-POM-5 by PhoenicisOrg.

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);
        }
    });
}
Also used : CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) CategoryDTO(org.phoenicis.repository.dto.CategoryDTO) RepositoryDTO(org.phoenicis.repository.dto.RepositoryDTO) Logger(org.slf4j.Logger) Files(java.nio.file.Files) ApplicationSidebarToggleGroupSkin(org.phoenicis.javafx.components.application.skin.ApplicationSidebarToggleGroupSkin) RepositoryManager(org.phoenicis.repository.RepositoryManager) ApplicationsFeaturePanel(org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) File(java.io.File) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) Platform(javafx.application.Platform) List(java.util.List) ThemeManager(org.phoenicis.javafx.themes.ThemeManager) Optional(java.util.Optional) URI(java.net.URI) Path(java.nio.file.Path) Path(java.nio.file.Path) IOException(java.io.IOException) File(java.io.File)

Aggregations

CategoryDTO (org.phoenicis.repository.dto.CategoryDTO)27 IOException (java.io.IOException)10 ArrayList (java.util.ArrayList)10 ApplicationDTO (org.phoenicis.repository.dto.ApplicationDTO)10 File (java.io.File)7 URI (java.net.URI)7 Path (java.nio.file.Path)6 List (java.util.List)6 TypeDTO (org.phoenicis.repository.dto.TypeDTO)6 HashMap (java.util.HashMap)5 Optional (java.util.Optional)5 EngineCategoryDTO (org.phoenicis.engines.dto.EngineCategoryDTO)4 EngineSubCategoryDTO (org.phoenicis.engines.dto.EngineSubCategoryDTO)4 ApplicationsFeaturePanel (org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel)4 Collections (java.util.Collections)3 Consumer (java.util.function.Consumer)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2