Search in sources :

Example 6 with InstallationDTO

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

the class InstallationsFeaturePanelSkin method createContent.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<Node> createContent() {
    final FilteredList<InstallationDTO> filteredInstallations = ConcatenatedList.create(new MappedList<>(getControl().getInstallationCategories().sorted(Comparator.comparing(InstallationCategoryDTO::getName)), InstallationCategoryDTO::getInstallations)).filtered(getControl().getFilter()::filter);
    filteredInstallations.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedInstallationCategoryProperty()));
    final SortedList<InstallationDTO> sortedInstallations = filteredInstallations.sorted(Comparator.comparing(InstallationDTO::getName));
    final ObservableList<ListWidgetElement<InstallationDTO>> listWidgetEntries = new MappedList<>(sortedInstallations, ListWidgetElement::create);
    final CombinedListWidget<InstallationDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
    // bind direction: controller property -> skin property
    getControl().selectedInstallationProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            combinedListWidget.select(newValue);
        } else {
            combinedListWidget.deselect();
        }
    });
    // bind direction: skin property -> controller properties
    combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            final InstallationDTO selectedItem = newValue.getItem();
            getControl().setSelectedInstallation(selectedItem);
            getControl().setOpenedDetailsPanel(new Installation(selectedItem));
        } else {
            getControl().setSelectedInstallation(null);
            getControl().setOpenedDetailsPanel(new None());
        }
    });
    return new SimpleObjectProperty<>(combinedListWidget);
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) Installation(org.phoenicis.javafx.components.installation.panelstates.Installation) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO) None(org.phoenicis.javafx.components.common.panelstates.None)

Example 7 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project phoenicis 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);
    this.installationsView.closeDetailsView();
    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 8 with InstallationDTO

use of org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO in project phoenicis 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 9 with InstallationDTO

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

the class InstallationsFeaturePanelSkin method createContent.

/**
 * {@inheritDoc}
 */
@Override
public ObjectExpression<Node> createContent() {
    final FilteredList<InstallationDTO> filteredInstallations = ConcatenatedList.create(new MappedList<>(getControl().getInstallationCategories().sorted(Comparator.comparing(InstallationCategoryDTO::getName)), InstallationCategoryDTO::getInstallations)).filtered(getControl().getFilter()::filter);
    filteredInstallations.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedInstallationCategoryProperty()));
    final SortedList<InstallationDTO> sortedInstallations = filteredInstallations.sorted(Comparator.comparing(InstallationDTO::getName));
    final ObservableList<ListWidgetElement<InstallationDTO>> listWidgetEntries = new MappedList<>(sortedInstallations, ListWidgetElement::create);
    final CombinedListWidget<InstallationDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
    // bind direction: controller property -> skin property
    getControl().selectedInstallationProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            combinedListWidget.select(newValue);
        } else {
            combinedListWidget.deselect();
        }
    });
    // bind direction: skin property -> controller properties
    combinedListWidget.selectedElementProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            final InstallationDTO selectedItem = newValue.getItem();
            getControl().setSelectedInstallation(selectedItem);
            getControl().setOpenedDetailsPanel(new Installation(selectedItem));
        } else {
            getControl().setSelectedInstallation(null);
            getControl().setOpenedDetailsPanel(new None());
        }
    });
    return new SimpleObjectProperty<>(combinedListWidget);
}
Also used : MappedList(org.phoenicis.javafx.collections.MappedList) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CombinedListWidget(org.phoenicis.javafx.components.common.widgets.control.CombinedListWidget) Installation(org.phoenicis.javafx.components.installation.panelstates.Installation) ListWidgetElement(org.phoenicis.javafx.components.common.widgets.utils.ListWidgetElement) InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) InstallationCategoryDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationCategoryDTO) None(org.phoenicis.javafx.components.common.panelstates.None)

Example 10 with InstallationDTO

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

the class InstallationsFeaturePanelSkin method createInstallationDetailsPanel.

private DetailsPanel createInstallationDetailsPanel(Installation action) {
    final InstallationDTO installation = action.getInstallation();
    final DetailsPanel detailsPanel = new DetailsPanel();
    detailsPanel.setTitle(installation.getName());
    detailsPanel.setContent(installation.getNode());
    detailsPanel.setOnClose(getControl()::closeDetailsPanel);
    detailsPanel.prefWidthProperty().bind(getControl().widthProperty().divide(3));
    return detailsPanel;
}
Also used : InstallationDTO(org.phoenicis.javafx.views.mainwindow.installations.dto.InstallationDTO) OpenDetailsPanel(org.phoenicis.javafx.components.common.panelstates.OpenDetailsPanel) DetailsPanel(org.phoenicis.javafx.components.common.control.DetailsPanel)

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