Skip to content

Commit

Permalink
Merge pull request #280 from DropSnorz/feat/table-view
Browse files Browse the repository at this point in the history
Add plugin table view
  • Loading branch information
DropSnorz authored Jan 9, 2025
2 parents de1cc4c + 0fea25d commit 5f3c27b
Show file tree
Hide file tree
Showing 35 changed files with 1,112 additions and 640 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.owlplug.auth.controllers;

import com.owlplug.auth.services.AuthenticationService;
import com.owlplug.controls.DialogLayout;
import com.owlplug.core.components.LazyViewRegistry;
import com.owlplug.core.controllers.MainController;
import com.owlplug.core.controllers.dialogs.AbstractDialogController;
Expand Down Expand Up @@ -142,13 +143,10 @@ protected void onDialogShow() {
}

@Override
protected Node getBody() {
return viewRegistry.get(LazyViewRegistry.NEW_ACCOUNT_VIEW);
}

@Override
protected Node getHeading() {
return null;
protected DialogLayout getLayout() {
DialogLayout layout = new DialogLayout();
layout.setBody(viewRegistry.get(LazyViewRegistry.NEW_ACCOUNT_VIEW));
return layout;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class ApplicationDefaults {
public final Image tagImage = new Image(getClass().getResourceAsStream("/icons/tag-white-16.png"));
public final Image symlinkImage = new Image(getClass().getResourceAsStream("/icons/folderlink-grey-16.png"));
public final Image userImage = new Image(getClass().getResourceAsStream("/icons/user-white-32.png"));
public final Image rootDirectoryImage = new Image(getClass().getResourceAsStream("/icons/foldersearch-grey-16.png"));
public final Image scanDirectoryImage = new Image(getClass().getResourceAsStream("/icons/foldersearch-grey-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 @@ -112,6 +112,8 @@ public class ApplicationDefaults {
public static final String SHOW_DIALOG_DISABLE_PLUGIN_KEY = "SHOW_DIALOG_DISABLE_PLUGIN_KEY";
public static final String PROJECT_DIRECTORY_KEY = "PROJECT_DIRECTORY_KEY";

public static final String PLUGIN_PREFERRED_DISPLAY_KEY = "PLUGIN_PREFERRED_DISPLAY_KEY";

/**
* Creates a new ApplicationDefaults.
*/
Expand Down Expand Up @@ -228,6 +230,7 @@ public String getOwlPlugRegistryUrl() {
public String getStudiorackRegistryUrl() {
return env.getProperty("studiorack.registry.url");
}

public String getEnvProperty(String property) {
return env.getProperty(property);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.owlplug.core.dao.SymlinkDAO;
import com.owlplug.core.model.Plugin;
import com.owlplug.core.services.NativeHostService;
import com.owlplug.core.services.PluginService;
import com.owlplug.core.tasks.FileSyncTask;
import com.owlplug.core.tasks.PluginRemoveTask;
import com.owlplug.core.tasks.PluginSyncTask;
Expand All @@ -48,6 +49,8 @@ public class CoreTaskFactory extends BaseTaskFactory {
@Autowired
private PluginDAO pluginDAO;
@Autowired
private PluginService pluginService;
@Autowired
private PluginFootprintDAO pluginFootprintDAO;
@Autowired
private SymlinkDAO symlinkDAO;
Expand Down Expand Up @@ -122,24 +125,8 @@ public TaskExecutionContext createPluginSyncTask(String directoryScope) {
}

public TaskExecutionContext createFileStatSyncTask() {
Set<String> directorySet = new TreeSet<>();

if (prefs.getBoolean(ApplicationDefaults.VST2_DISCOVERY_ENABLED_KEY, false)) {
directorySet.add(prefs.get(ApplicationDefaults.VST_DIRECTORY_KEY, ""));
directorySet.addAll(prefs.getList(ApplicationDefaults.VST2_EXTRA_DIRECTORY_KEY));
}
if (prefs.getBoolean(ApplicationDefaults.VST3_DISCOVERY_ENABLED_KEY, false)) {
directorySet.add(prefs.get(ApplicationDefaults.VST3_DIRECTORY_KEY, ""));
directorySet.addAll(prefs.getList(ApplicationDefaults.VST3_EXTRA_DIRECTORY_KEY));
}
if (prefs.getBoolean(ApplicationDefaults.AU_DISCOVERY_ENABLED_KEY, false)) {
directorySet.add(prefs.get(ApplicationDefaults.AU_DIRECTORY_KEY, ""));
directorySet.addAll(prefs.getList(ApplicationDefaults.AU_EXTRA_DIRECTORY_KEY));
}
if (prefs.getBoolean(ApplicationDefaults.LV2_DISCOVERY_ENABLED_KEY, false)) {
directorySet.add(prefs.get(ApplicationDefaults.LV2_DIRECTORY_KEY, ""));
directorySet.addAll(prefs.getList(ApplicationDefaults.LV2_EXTRA_DIRECTORY_KEY));
}
Set<String> directorySet = pluginService.getDirectoriesExplorationSet();
FileSyncTask task = new FileSyncTask(fileStatDAO, directorySet.stream().toList());

return create(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,6 @@ public Dialog newDialog() {
return dialog;
}

/**
* Creates a new dialog.
*
* @param body - dialog body
* @return
*/
public Dialog newDialog(Node body) {

DialogLayout layout = new DialogLayout();
layout.setBody(body);
return newDialog(layout);
}

/**
* Creates a new dialog.
*
* @param body - dialog body
* @param heading - dialog header
* @return
*/
public Dialog newDialog(Node body, Node heading) {

DialogLayout layout = new DialogLayout();
layout.setBody(body);
layout.setHeading(heading);
return newDialog(layout);
}

/**
* Creates a new dialog.
Expand All @@ -90,37 +63,13 @@ public Dialog newDialog(Node body, Node heading) {
* @param body - dialog body
* @return the dialog
*/
public Dialog newDialog(double width, double height, Node body) {

DialogLayout layout = new DialogLayout();
public Dialog newDialog(double width, double height, DialogLayout layout) {
layout.setMaxSize(width, height);
layout.setPrefSize(width, height);
layout.setBody(body);

return newDialog(layout);

}

/**
* Creates a new dialog.
*
* @param width - dialog width
* @param height - dialog height
* @param body - dialog body
* @param heading - dialog header
* @return the dialog
*/
public Dialog newDialog(double width, double height, Node body, Node heading) {

DialogLayout layout = new DialogLayout();
layout.setMaxSize(width, height);
layout.setPrefSize(width, height);
layout.setBody(body);
layout.setHeading(heading);

return newDialog(layout);

}

/**
* Creates a new dialog based on dialog layout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.owlplug.core.components.ApplicationDefaults;
import com.owlplug.core.components.CoreTaskFactory;
import com.owlplug.core.components.ImageCache;
import com.owlplug.core.controllers.dialogs.DisablePluginDialogController;
import com.owlplug.core.model.Plugin;
import com.owlplug.core.model.PluginComponent;
import com.owlplug.core.services.PluginService;
Expand All @@ -35,9 +36,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.effect.ColorAdjust;
Expand All @@ -49,7 +48,6 @@
import javafx.scene.layout.BackgroundRepeat;
import javafx.scene.layout.BackgroundSize;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import org.controlsfx.control.ToggleSwitch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
Expand All @@ -65,6 +63,8 @@ public class PluginInfoController extends BaseController {
private ImageCache imageCache;
@Autowired
private CoreTaskFactory coreTaskFactory;
@Autowired
private DisablePluginDialogController disableController;

@FXML
private Pane pluginScreenshotPane;
Expand Down Expand Up @@ -101,7 +101,7 @@ public class PluginInfoController extends BaseController {
@FXML
private ToggleSwitch nativeDiscoveryToggleButton;

private Plugin currentPlugin = null;
private Plugin plugin = null;
private ArrayList<String> knownPluginImages = new ArrayList<>();

/**
Expand All @@ -126,35 +126,40 @@ public void initialize() {

disableButton.setOnAction(e -> {
if (this.getPreferences().getBoolean(ApplicationDefaults.SHOW_DIALOG_DISABLE_PLUGIN_KEY, true)) {
this.showDisableDialog();
this.disableController.setPlugin(plugin);
this.disableController.show();
} else {
pluginService.disablePlugin(currentPlugin);
setPlugin(currentPlugin);
pluginsController.refreshPluginTree();
this.disableController.disablePluginWithoutPrompt(plugin);
}

});

enableButton.setOnAction(e -> {
pluginService.enablePlugin(currentPlugin);
setPlugin(currentPlugin);
pluginsController.refreshPluginTree();
pluginService.enablePlugin(plugin);
setPlugin(plugin);
pluginsController.refresh();
});

pluginComponentListView.setCellFactory(new PluginComponentCellFactory(this.getApplicationDefaults()));

nativeDiscoveryToggleButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
if (currentPlugin != null && currentPlugin.getFootprint() != null) {
currentPlugin.getFootprint().setNativeDiscoveryEnabled(newValue);
pluginService.save(currentPlugin.getFootprint());
if (plugin != null && plugin.getFootprint() != null) {
plugin.getFootprint().setNativeDiscoveryEnabled(newValue);
pluginService.save(plugin.getFootprint());
}

});

}

public void setPlugin(Plugin plugin) {
this.currentPlugin = plugin;
this.plugin = plugin;
refresh();
}

public void refresh() {

if (plugin == null) {
return;
}
pluginFormatIcon.setImage(this.getApplicationDefaults().getPluginFormatIcon(plugin.getFormat()));
pluginFormatLabel.setText(plugin.getFormat().getText() + " Plugin");
pluginTitleLabel.setText(plugin.getName());
Expand Down Expand Up @@ -190,13 +195,13 @@ public void setPlugin(Plugin plugin) {
}

private void setPluginImage() {
if (currentPlugin.getScreenshotUrl() == null || currentPlugin.getScreenshotUrl().isEmpty()) {
String url = pluginService.resolveImageUrl(currentPlugin);
currentPlugin.setScreenshotUrl(url);
pluginService.save(currentPlugin);
if (plugin.getScreenshotUrl() == null || plugin.getScreenshotUrl().isEmpty()) {
String url = pluginService.resolveImageUrl(plugin);
plugin.setScreenshotUrl(url);
pluginService.save(plugin);
}

String url = currentPlugin.getScreenshotUrl();
String url = plugin.getScreenshotUrl();
if (knownPluginImages.contains(url) && !imageCache.contains(url)) {

BackgroundImage bgImg = new BackgroundImage(this.getApplicationDefaults().pluginPlaceholderImage,
Expand Down Expand Up @@ -224,7 +229,7 @@ private void showUninstallDialog() {
DialogLayout layout = new DialogLayout();

layout.setHeading(new Label("Remove plugin"));
layout.setBody(new Label("Do you really want to remove " + currentPlugin.getName()
layout.setBody(new Label("Do you really want to remove " + plugin.getName()
+ " ? This will permanently delete the file from your hard drive."));

Button cancelButton = new Button("Cancel");
Expand All @@ -235,62 +240,14 @@ private void showUninstallDialog() {
Button removeButton = new Button("Remove");
removeButton.setOnAction(removeEvent -> {
dialog.close();
coreTaskFactory.createPluginRemoveTask(currentPlugin)
.setOnSucceeded(x -> pluginsController.clearAndFillPluginTree()).schedule();
coreTaskFactory.createPluginRemoveTask(plugin)
.setOnSucceeded(x -> pluginsController.displayPlugins()).schedule();
});
removeButton.getStyleClass().add("button-danger");

layout.setActions(removeButton, cancelButton);
dialog.setContent(layout);
dialog.show();
}

private void showDisableDialog() {

DialogLayout layout = new DialogLayout();

layout.setHeading(new Label("Disable plugin"));

VBox vbox = new VBox(10);
Label dialogLabel = new Label(
"Disabling a plugin will rename the plugin file by updating the extension. "
+ "The suffix \".disabled\" will be appended to the filename causing the DAW to ignore the plugin. "
+ "You can reactivate the plugin at any time from OwlPlug or by renaming the file manually.");
dialogLabel.setWrapText(true);
vbox.getChildren().add(dialogLabel);

Label noteLabel = new Label("You may need admin privileges to rename plugins");
noteLabel.getStyleClass().add("label-disabled");
vbox.getChildren().add(noteLabel);

CheckBox displayDialog = new CheckBox("Don't show me this message again");
VBox.setMargin(displayDialog, new Insets(20,0,0,0));
displayDialog.setSelected(!getPreferences().getBoolean(ApplicationDefaults.SHOW_DIALOG_DISABLE_PLUGIN_KEY, true));
displayDialog.selectedProperty().addListener((observable, oldValue, newValue) -> {
this.getPreferences().putBoolean(ApplicationDefaults.SHOW_DIALOG_DISABLE_PLUGIN_KEY, !newValue);
});
vbox.getChildren().add(displayDialog);
layout.setBody(vbox);

Dialog dialog = this.getDialogManager().newDialog();

Button cancelButton = new Button("Cancel");
cancelButton.setOnAction(cancelEvent -> {
dialog.close();
});

Button disableButton = new Button("Disable Plugin");
disableButton.setOnAction(removeEvent -> {
pluginService.disablePlugin(currentPlugin);
setPlugin(currentPlugin);
pluginsController.refreshPluginTree();
dialog.close();
});

layout.setActions(disableButton, cancelButton);
layout.setPrefSize(600, 280);
dialog.setContent(layout);
dialog.show();
}

}
Loading

0 comments on commit 5f3c27b

Please sign in to comment.