use of org.phoenicis.javafx.components.library.panelstates.ShortcutInformation in project POL-POM-5 by PlayOnLinux.
the class LibraryFeaturePanelSkin method createCombinedListWidget.
private CombinedListWidget<ShortcutDTO> createCombinedListWidget() {
final FilteredList<ShortcutDTO> filteredShortcuts = ConcatenatedList.create(new MappedList<>(getControl().getCategories().sorted(Comparator.comparing(ShortcutCategoryDTO::getName)), ShortcutCategoryDTO::getShortcuts)).filtered(getControl().getFilter()::filter);
filteredShortcuts.predicateProperty().bind(Bindings.createObjectBinding(() -> getControl().getFilter()::filter, getControl().getFilter().searchTermProperty(), getControl().getFilter().selectedShortcutCategoryProperty()));
final SortedList<ShortcutDTO> sortedShortcuts = filteredShortcuts.sorted(Comparator.comparing(shortcut -> shortcut.getInfo().getName()));
final ObservableList<ListWidgetElement<ShortcutDTO>> listWidgetEntries = new MappedList<>(sortedShortcuts, ListWidgetElement::create);
final CombinedListWidget<ShortcutDTO> combinedListWidget = new CombinedListWidget<>(listWidgetEntries, this.selectedListWidget);
// bind direction: controller property -> skin property
getControl().selectedShortcutProperty().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 ShortcutDTO selectedItem = newValue.getItem();
final MouseEvent event = newValue.getEvent();
getControl().setSelectedShortcut(selectedItem);
getControl().setOpenedDetailsPanel(new ShortcutInformation(selectedItem));
if (event.getClickCount() == 2) {
getControl().runShortcut(selectedItem);
}
} else {
getControl().setSelectedShortcut(null);
getControl().setOpenedDetailsPanel(new None());
}
});
return combinedListWidget;
}
use of org.phoenicis.javafx.components.library.panelstates.ShortcutInformation in project POL-POM-5 by PlayOnLinux.
the class LibraryFeaturePanelSkin method createShortcutInformationDetailsPanel.
private DetailsPanel createShortcutInformationDetailsPanel(ShortcutInformation action) {
final ShortcutInformationPanel shortcutInformationPanel = new ShortcutInformationPanel();
shortcutInformationPanel.javaFxSettingsManagerProperty().bind(getControl().javaFxSettingsManagerProperty());
shortcutInformationPanel.setShortcut(action.getShortcut());
shortcutInformationPanel.objectMapperProperty().bind(getControl().objectMapperProperty());
shortcutInformationPanel.setOnShortcutRun(getControl()::runShortcut);
shortcutInformationPanel.setOnShortcutStop(getControl()::stopShortcut);
shortcutInformationPanel.setOnShortcutUninstall(getControl()::uninstallShortcut);
shortcutInformationPanel.setOnShortcutEdit(shortcut -> getControl().setOpenedDetailsPanel(new ShortcutEditing(getControl().getSelectedShortcut())));
final DetailsPanel detailsPanel = new DetailsPanel();
detailsPanel.titleProperty().bind(StringBindings.map(getControl().selectedShortcutProperty(), shortcut -> shortcut.getInfo().getName()));
detailsPanel.setContent(shortcutInformationPanel);
detailsPanel.setOnClose(getControl()::closeDetailsPanel);
detailsPanel.prefWidthProperty().bind(getControl().widthProperty().divide(3));
return detailsPanel;
}
Aggregations