Search in sources :

Example 1 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project POL-POM-5 by PhoenicisOrg.

the class InstallationsUtils method mergeCategories.

private InstallationCategoryDTO mergeCategories(InstallationCategoryDTO leftCategory, InstallationCategoryDTO rightCategory) {
    final Map<String, InstallationDTO> leftInstallations = createSortedMap(leftCategory.getInstallations(), InstallationDTO::getId);
    final Map<String, InstallationDTO> rightInstallations = createSortedMap(rightCategory.getInstallations(), InstallationDTO::getId);
    final SortedMap<String, InstallationDTO> mergedInstallations = new TreeMap<>(rightInstallations);
    for (Map.Entry<String, InstallationDTO> entry : leftInstallations.entrySet()) {
        final InstallationDTO application = entry.getValue();
        if (mergedInstallations.containsKey(entry.getKey())) {
            LOGGER.error(String.format("Installation %s exists already!", entry.getKey()));
        } else {
            mergedInstallations.put(entry.getKey(), application);
        }
    }
    final List<InstallationDTO> installations = new ArrayList<>(mergedInstallations.values());
    installations.sort(InstallationDTO.nameComparator());
    return new InstallationCategoryDTO.Builder().withId(leftCategory.getId()).withName(leftCategory.getName()).withInstallations(installations).withIcon(leftCategory.getIcon()).build();
}
Also used : InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)

Example 2 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project POL-POM-5 by PlayOnLinux.

the class MainWindow method createInstallationsTab.

private Tab createInstallationsTab(InstallationsFeaturePanel installationsFeaturePanel) {
    final Tab installationsTab = new Tab(tr("Installations"), installationsFeaturePanel);
    installationsTab.setClosable(false);
    final ConcatenatedList<InstallationDTO> installations = ConcatenatedList.create(new MappedList<>(installationsFeaturePanel.getInstallationCategories(), InstallationCategoryDTO::getInstallations));
    // a binding containing the number of currently active installations
    final IntegerBinding openInstallations = Bindings.createIntegerBinding(installations::size, installations);
    final TabIndicator indicator = new TabIndicator();
    indicator.textProperty().bind(StringBindings.map(openInstallations, numberOfInstallations -> {
        if (numberOfInstallations.intValue() < 10) {
            return String.valueOf(numberOfInstallations);
        } else {
            return "+";
        }
    }));
    // only show the tab indicator if at least one active installation exists
    installationsTab.graphicProperty().bind(Bindings.when(Bindings.notEqual(openInstallations, 0)).then(indicator).otherwise(new SimpleObjectProperty<>()));
    return installationsTab;
}
Also used : Scene(javafx.scene.Scene) LibraryFeaturePanel(org.phoenicis.javafx.components.library.control.LibraryFeaturePanel) TabIndicator(org.phoenicis.javafx.components.common.control.TabIndicator) IntegerBinding(javafx.beans.binding.IntegerBinding) StringBindings(org.phoenicis.javafx.utils.StringBindings) MappedList(org.phoenicis.javafx.collections.MappedList) Bindings(javafx.beans.binding.Bindings) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) TabPane(javafx.scene.control.TabPane) JavaFXApplication(org.phoenicis.javafx.JavaFXApplication) ContainersFeaturePanel(org.phoenicis.javafx.components.container.control.ContainersFeaturePanel) InstallationsFeaturePanel(org.phoenicis.javafx.components.installation.control.InstallationsFeaturePanel) SettingsView(org.phoenicis.javafx.views.mainwindow.settings.SettingsView) ApplicationsFeaturePanel(org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Platform(javafx.application.Platform) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ThemeManager(org.phoenicis.javafx.themes.ThemeManager) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) PhoenicisScene(org.phoenicis.javafx.views.common.PhoenicisScene) Image(javafx.scene.image.Image) EnginesView(org.phoenicis.javafx.views.mainwindow.engines.EnginesView) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) IntegerBinding(javafx.beans.binding.IntegerBinding) TabIndicator(org.phoenicis.javafx.components.common.control.TabIndicator)

Example 3 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project POL-POM-5 by PlayOnLinux.

the class SetupUiFactoryJavaFX method createSetupWindow.

/**
 * creates a setup UI to install an application
 * @param title title of the setup UI
 * @param miniature miniature which is shown in the "Installations" tab (usually the miniature of the installed
 *            application)
 * @param installationType apps/engines
 * @return setup window
 */
@Override
public SetupUi createSetupWindow(String title, Optional<URI> miniature, InstallationType installationType) {
    final SetupUiJavaFXImplementation setupWindow = new SetupUiJavaFXImplementation(title, this.operatingSystemFetcher, this.themeManager);
    final InstallationDTO installationDTO = new InstallationDTO.Builder().withCategory(installationType).withId(title + "_" + new Date().getTime()).withName(title).withMiniature(miniature.orElse(null)).withNode(setupWindow.getContent()).build();
    this.installationsView.addInstallation(installationDTO);
    setupWindow.setOnShouldClose(() -> this.installationsView.removeInstallation(installationDTO));
    return setupWindow;
}
Also used : InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) Date(java.util.Date)

Example 4 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project POL-POM-5 by PhoenicisOrg.

the class MainWindow method createInstallationsTab.

private Tab createInstallationsTab(InstallationsFeaturePanel installationsFeaturePanel) {
    final Tab installationsTab = new Tab(tr("Installations"), installationsFeaturePanel);
    installationsTab.setClosable(false);
    final ConcatenatedList<InstallationDTO> installations = ConcatenatedList.create(new MappedList<>(installationsFeaturePanel.getInstallationCategories(), InstallationCategoryDTO::getInstallations));
    // a binding containing the number of currently active installations
    final IntegerBinding openInstallations = Bindings.createIntegerBinding(installations::size, installations);
    final TabIndicator indicator = new TabIndicator();
    indicator.textProperty().bind(StringBindings.map(openInstallations, numberOfInstallations -> {
        if (numberOfInstallations.intValue() < 10) {
            return String.valueOf(numberOfInstallations);
        } else {
            return "+";
        }
    }));
    // only show the tab indicator if at least one active installation exists
    installationsTab.graphicProperty().bind(Bindings.when(Bindings.notEqual(openInstallations, 0)).then(indicator).otherwise(new SimpleObjectProperty<>()));
    return installationsTab;
}
Also used : Scene(javafx.scene.Scene) LibraryFeaturePanel(org.phoenicis.javafx.components.library.control.LibraryFeaturePanel) TabIndicator(org.phoenicis.javafx.components.common.control.TabIndicator) IntegerBinding(javafx.beans.binding.IntegerBinding) StringBindings(org.phoenicis.javafx.utils.StringBindings) MappedList(org.phoenicis.javafx.collections.MappedList) Bindings(javafx.beans.binding.Bindings) ErrorDialog(org.phoenicis.javafx.dialogs.ErrorDialog) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) TabPane(javafx.scene.control.TabPane) JavaFXApplication(org.phoenicis.javafx.JavaFXApplication) ContainersFeaturePanel(org.phoenicis.javafx.components.container.control.ContainersFeaturePanel) InstallationsFeaturePanel(org.phoenicis.javafx.components.installation.control.InstallationsFeaturePanel) SettingsView(org.phoenicis.javafx.views.mainwindow.settings.SettingsView) ApplicationsFeaturePanel(org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) Platform(javafx.application.Platform) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) ThemeManager(org.phoenicis.javafx.themes.ThemeManager) ConcatenatedList(org.phoenicis.javafx.collections.ConcatenatedList) PhoenicisScene(org.phoenicis.javafx.views.common.PhoenicisScene) Image(javafx.scene.image.Image) EnginesView(org.phoenicis.javafx.views.mainwindow.engines.EnginesView) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) IntegerBinding(javafx.beans.binding.IntegerBinding) TabIndicator(org.phoenicis.javafx.components.common.control.TabIndicator)

Example 5 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project POL-POM-5 by PhoenicisOrg.

the class SetupUiFactoryJavaFX method createSetupWindow.

/**
 * creates a setup UI to install an application
 * @param title title of the setup UI
 * @param miniature miniature which is shown in the "Installations" tab (usually the miniature of the installed
 *            application)
 * @param installationType apps/engines
 * @return setup window
 */
@Override
public SetupUi createSetupWindow(String title, Optional<URI> miniature, InstallationType installationType) {
    final SetupUiJavaFXImplementation setupWindow = new SetupUiJavaFXImplementation(title, this.operatingSystemFetcher, this.themeManager);
    final InstallationDTO installationDTO = new InstallationDTO.Builder().withCategory(installationType).withId(title + "_" + new Date().getTime()).withName(title).withMiniature(miniature.orElse(null)).withNode(setupWindow.getContent()).build();
    this.installationsView.addInstallation(installationDTO);
    setupWindow.setOnShouldClose(() -> this.installationsView.removeInstallation(installationDTO));
    return setupWindow;
}
Also used : InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) Date(java.util.Date)

Aggregations

InstallationDTO (org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO)13 InstallationCategoryDTO (org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO)8 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)4 MappedList (org.phoenicis.javafx.collections.MappedList)4 Date (java.util.Date)3 Platform (javafx.application.Platform)2 Bindings (javafx.beans.binding.Bindings)2 IntegerBinding (javafx.beans.binding.IntegerBinding)2 Scene (javafx.scene.Scene)2 Tab (javafx.scene.control.Tab)2 TabPane (javafx.scene.control.TabPane)2 Image (javafx.scene.image.Image)2 Stage (javafx.stage.Stage)2 Localisation.tr (org.phoenicis.configuration.localisation.Localisation.tr)2 JavaFXApplication (org.phoenicis.javafx.JavaFXApplication)2 ConcatenatedList (org.phoenicis.javafx.collections.ConcatenatedList)2 ApplicationsFeaturePanel (org.phoenicis.javafx.components.application.control.ApplicationsFeaturePanel)2 DetailsPanel (org.phoenicis.javafx.components.common.control.DetailsPanel)2 TabIndicator (org.phoenicis.javafx.components.common.control.TabIndicator)2 None (org.phoenicis.javafx.components.common.panelstates.None)2