Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Philip Emery
Christian Derr
Antti Aro
Kim T
Ramiro Montes De Oca
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.owlplug.core.model.OperatingSystem;
import com.owlplug.core.model.RuntimePlatform;
import com.owlplug.explore.model.RemotePackage;
import com.owlplug.plugin.model.PluginFormat;
import com.owlplug.plugin.model.PluginType;
import com.owlplug.project.model.DawApplication;
Expand All @@ -32,7 +31,6 @@
import java.util.List;
import java.util.stream.Collectors;
import javafx.scene.image.Image;
import org.kordamp.ikonli.javafx.FontIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -64,7 +62,7 @@ public class ApplicationDefaults {
public final Image vst3Image = new Image(getClass().getResourceAsStream("/icons/vst3-green-16.png"));
public final Image auImage = new Image(getClass().getResourceAsStream("/icons/au-purple-16.png"));
public final Image lv2Image = new Image(getClass().getResourceAsStream("/icons/lv2-orange-16.png"));
public final Image pluginComponentImage = new Image(getClass().getResourceAsStream("/icons/cube-white-16.png"));
public final Image defaultFormat = new Image(getClass().getResourceAsStream("/icons/format-white-16.png"));
public final Image verifiedSourceImage = new Image(getClass().getResourceAsStream("/icons/doublecheck-grey-16.png"));
public final Image suggestedSourceImage = new Image(
ApplicationDefaults.class.getResourceAsStream("/icons/check-grey-16.png"));
Expand Down Expand Up @@ -160,14 +158,14 @@ public RuntimePlatform getRuntimePlatform() {
*/
public Image getPluginFormatIcon(PluginFormat format) {
if (format == null) {
return pluginComponentImage;
return defaultFormat;
}
return switch (format) {
case VST2 -> vst2Image;
case VST3 -> vst3Image;
case AU -> auImage;
case LV2 -> lv2Image;
default -> pluginComponentImage;
default -> defaultFormat;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public static String ellipsis(String input, int maxLength, int clearEndLength) {
}
}

public static String capitalize(String str) {
if (str == null || str.isEmpty()) {
return str;
}
return Character.toUpperCase(str.charAt(0)) + str.substring(1);
}

public static String getStackTraceAsString(Throwable throwable) {
if (throwable == null) {
return "null throwable";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* OwlPlug
* Copyright (C) 2021 Arthur <dropsnorz@gmail.com>
*
* This file is part of OwlPlug.
*
* OwlPlug is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3
* as published by the Free Software Foundation.
*
* OwlPlug is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OwlPlug. If not, see <https://www.gnu.org/licenses/>.
*/

package com.owlplug.plugin.components;

import com.owlplug.plugin.model.IPlugin;
import com.owlplug.plugin.model.Plugin;
import com.owlplug.plugin.model.PluginComponent;
import com.owlplug.plugin.model.PluginFormat;
import com.owlplug.plugin.model.PluginType;
import java.util.function.Predicate;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableSet;
import org.springframework.stereotype.Component;

@Component
public class PluginFilterState {

private final ObservableSet<PluginFormat> selectedFormats = FXCollections.observableSet();
private final ObservableSet<PluginType> selectedTypes = FXCollections.observableSet();
private final ObservableSet<String> selectedManufacturers = FXCollections.observableSet();
private final ObservableSet<String> selectedCategories = FXCollections.observableSet();
private final ObjectProperty<Predicate<IPlugin>> predicate = new SimpleObjectProperty<>();

public PluginFilterState() {
predicate.bind(Bindings.createObjectBinding(this::buildPredicate,
selectedFormats, selectedTypes, selectedManufacturers, selectedCategories));
}

private Predicate<IPlugin> buildPredicate() {
if (selectedFormats.isEmpty() && selectedTypes.isEmpty()
&& selectedManufacturers.isEmpty() && selectedCategories.isEmpty()) {
return null;
}
return plugin -> {
if (plugin instanceof PluginComponent component) {
return matchesFormat(component.asPlugin().getFormat())
&& matchesType(component.getType())
&& matchesManufacturer(component.getManufacturerName())
&& matchesCategory(component.getCategory());
} else {
Plugin p = (Plugin) plugin;
return matchesFormat(p.getFormat())
&& (matchesType(p.getType())
|| p.getComponents().stream().anyMatch(c -> matchesType(c.getType())))
&& (matchesManufacturer(p.getManufacturerName())
|| p.getComponents().stream().anyMatch(c -> matchesManufacturer(c.getManufacturerName())))
&& (matchesCategory(p.getCategory())
|| p.getComponents().stream().anyMatch(c -> matchesCategory(c.getCategory())));
}
};
}

private boolean matchesFormat(PluginFormat format) {
return selectedFormats.isEmpty() || selectedFormats.contains(format);
}

private boolean matchesType(PluginType type) {
return selectedTypes.isEmpty() || selectedTypes.contains(type);
}

private boolean matchesManufacturer(String manufacturer) {
return selectedManufacturers.isEmpty() || selectedManufacturers.contains(manufacturer);
}

private boolean matchesCategory(String category) {
return selectedCategories.isEmpty() || selectedCategories.contains(category);
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

public ObservableSet<PluginFormat> getSelectedFormats() {
return selectedFormats;
}

public ObservableSet<PluginType> getSelectedTypes() {
return selectedTypes;
}

public ObservableSet<String> getSelectedManufacturers() {
return selectedManufacturers;
}

public ObservableSet<String> getSelectedCategories() {
return selectedCategories;
}

public ObjectProperty<Predicate<IPlugin>> predicateProperty() {
return predicate;
}

public void clearAll() {
selectedFormats.clear();
selectedTypes.clear();
selectedManufacturers.clear();
selectedCategories.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.owlplug.plugin.model.PluginComponent;
import com.owlplug.plugin.services.PluginService;
import com.owlplug.plugin.ui.PluginFormatBadgeView;
import com.owlplug.plugin.ui.PluginKindBadgeView;
import com.owlplug.plugin.ui.PluginStateView;
import java.util.ArrayList;
import java.util.Optional;
Expand Down Expand Up @@ -82,13 +83,15 @@ public class ComponentInfoController extends BaseController {
public void initialize() {
componentProperty.addListener(e -> refresh());
pluginScreenshotPane.setEffect(new ColorAdjust(0, 0, -0.6, 0));
pluginFormatBadgeContainer.setSpacing(5);

}

public void refresh() {
PluginComponent component = componentProperty.get();
pluginFormatBadgeContainer.getChildren().setAll(
new PluginFormatBadgeView(component.getPlugin().getFormat(), this.getApplicationDefaults()));
new PluginKindBadgeView(component, this.getApplicationDefaults()),
new Label(component.asPlugin().getFormat().getName() + " Component"));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
pluginTitleLabel.setText(component.getName());
pluginNameLabel.setText(Optional.ofNullable(component.getDescriptiveName()).orElse(component.getName()));
pluginVersionLabel.setText(Optional.ofNullable(component.getVersion()).orElse("Unknown"));
Expand Down
Loading
Loading