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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import com.owlplug.plugin.ui.PluginStateView;
import java.util.ArrayList;
import java.util.Optional;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.effect.ColorAdjust;
Expand Down Expand Up @@ -70,20 +72,22 @@ public class ComponentInfoController extends BaseController {
private PluginStateView pluginStateView;
@FXML
private Label pluginReferenceLabel;
private PluginComponent currentComponent = null;
private ArrayList<String> knownPluginImages = new ArrayList<>();

private final ObjectProperty<PluginComponent> componentProperty = new SimpleObjectProperty<>();
private final ArrayList<String> knownPluginImages = new ArrayList<>();

/**
* FXML initialize method.
*/
@FXML
public void initialize() {
componentProperty.addListener(e -> refresh());
pluginScreenshotPane.setEffect(new ColorAdjust(0, 0, -0.6, 0));

}

public void setComponent(PluginComponent component) {
this.currentComponent = component;
public void refresh() {
PluginComponent component = componentProperty.get();
pluginFormatIcon.setImage(this.getApplicationDefaults().getPluginFormatIcon(component.getPlugin().getFormat()));
pluginFormatLabel.setText(component.getPlugin().getFormat().getText() + " Plugin Component");
pluginTitleLabel.setText(component.getName());
Expand All @@ -99,7 +103,7 @@ public void setComponent(PluginComponent component) {
}

private void setPluginImage() {
Plugin currentPlugin = currentComponent.getPlugin();
Plugin currentPlugin = componentProperty.get().getPlugin();

String url = currentPlugin.getScreenshotUrl();
if (url == null || url.isEmpty()) {
Expand Down Expand Up @@ -133,4 +137,8 @@ private void setPluginImage() {
}
}

public ObjectProperty<PluginComponent> componentProperty() {
return componentProperty;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import java.io.File;
import java.util.List;
import java.util.Optional;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -88,15 +90,17 @@ public class DirectoryInfoController extends BaseController {
private TableColumn<FileStat, String> fileSizeColumn;
private PieChart pieChart;

private PluginDirectory pluginDirectory;
private final ObjectProperty<PluginDirectory> pluginDirectoryProperty = new SimpleObjectProperty<>();

/**
* FXML Initialize.
*/
public void initialize() {

pluginDirectoryProperty.addListener(e -> refresh());

openDirectoryButton.setOnAction(e -> {
PlatformUtils.openFromDesktop(pluginDirectory.getPath());
PlatformUtils.openFromDesktop(pluginDirectoryProperty.get().getPath());
});

pluginDirectoryListView.setCellFactory(new PluginListCellFactory(this.getApplicationDefaults()));
Expand All @@ -105,6 +109,8 @@ public void initialize() {
Dialog dialog = this.getDialogManager().newDialog();
DialogLayout layout = new DialogLayout();

PluginDirectory pluginDirectory = pluginDirectoryProperty.get();

layout.setHeading(new Label("Remove directory"));
layout.setBody(new Label("Do you really want to remove " + pluginDirectory.getName()
+ " and all of its content ? This will permanently delete the file from your hard drive."));
Expand Down Expand Up @@ -160,8 +166,13 @@ protected void layoutChartChildren(double top, double left, double contentWidth,

}

public void setPluginDirectory(PluginDirectory pluginDirectory) {
this.pluginDirectory = pluginDirectory;
/**
* Refresh directory info.
* Most database accesses are performed in this method and expected to be run on
* UI thread to work around a bug with charts display with concurrent updates.
*/
public void refresh() {
PluginDirectory pluginDirectory = pluginDirectoryProperty.get();
directoryPathTextField.setText(pluginDirectory.getPath());
directoryNameLabel.setText(pluginDirectory.getName());
pluginDirectoryListView.getItems().setAll(pluginDirectory.getPluginList());
Expand All @@ -175,19 +186,15 @@ public void setPluginDirectory(PluginDirectory pluginDirectory) {
path = path.substring(0, path.length() - 1);
}

directoryPluginsTab.setText("Plugins (" + pluginDirectory.getPluginList().size() + ")");

Optional<FileStat> directoryStat = fileStatRepository.findByPath(path);
directoryStat.ifPresent(fileStat -> directoryMetricsTab.setText(
FileUtils.humanReadableByteCount(fileStat.getLength(), true)));

directoryPluginsTab.setText("Plugins (" + pluginDirectory.getPluginList().size() + ")");
FileUtils.humanReadableByteCount(fileStat.getLength(), true)));

List<FileStat> fileStats = fileStatRepository.findByParentPathOrderByLengthDesc(path);
directoryFilesTab.setText("Files (" + fileStats.size() + ")");

ObservableList<FileStat> obsStats = FXCollections.observableArrayList();
obsStats.addAll(fileStats);
directoryFilesTableView.setItems(obsStats);

directoryFilesTableView.setItems(FXCollections.observableArrayList(fileStats));
pieChart.setData(createStatChartBuckets(fileStats));
pieChart.layout();
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Expand All @@ -214,5 +221,9 @@ private ObservableList<PieChart.Data> createStatChartBuckets(List<FileStat> file
return chartData;
}

public ObjectProperty<PluginDirectory> pluginDirectoryProperty() {
return pluginDirectoryProperty;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ public void setNode(Object node) {
componentInfoView.setVisible(false);

if (node instanceof Plugin) {
pluginInfoController.setPlugin((Plugin) node);
pluginInfoController.pluginProperty().set((Plugin) node);
pluginInfoView.setVisible(true);
}
if (node instanceof PluginDirectory) {
directoryInfoController.setPluginDirectory((PluginDirectory) node);
directoryInfoController.pluginDirectoryProperty().set((PluginDirectory) node);
directoryInfoView.setVisible(true);
}
if (node instanceof Symlink) {
symlinkInfoController.setSymlink((Symlink) node);
symlinkInfoController.symlinkProperty().set((Symlink) node);
symlinkInfoView.setVisible(true);
}
if (node instanceof PluginComponent) {
componentInfoController.setComponent((PluginComponent) node);
componentInfoController.componentProperty().set((PluginComponent) node);
componentInfoView.setVisible(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
Expand Down Expand Up @@ -107,15 +110,16 @@ public class PluginInfoController extends BaseController {
@FXML
private ToggleSwitch nativeDiscoveryToggleButton;

private Plugin plugin = null;
private ArrayList<String> knownPluginImages = new ArrayList<>();
private final ObjectProperty<Plugin> pluginProperty = new SimpleObjectProperty<Plugin>();
private final ArrayList<String> knownPluginImages = new ArrayList<>();

/**
* FXML initialize method.
*/
@FXML
public void initialize() {

pluginProperty.addListener(e -> refresh());
pluginScreenshotPane.setEffect(new ColorAdjust(0, 0, -0.6, 0));

openDirectoryButton.setGraphic(new ImageView(this.getApplicationDefaults().directoryImage));
Expand All @@ -130,7 +134,9 @@ public void initialize() {

});


disableButton.setOnAction(e -> {
Plugin plugin = pluginProperty.get();
if (this.getPreferences().getBoolean(ApplicationDefaults.SHOW_DIALOG_DISABLE_PLUGIN_KEY, true)) {
this.disableController.setPlugin(plugin);
this.disableController.show();
Expand All @@ -140,28 +146,25 @@ public void initialize() {
});

enableButton.setOnAction(e -> {
pluginService.enablePlugin(plugin);
setPlugin(plugin);
Plugin plugin = pluginProperty.get();
CompletableFuture.runAsync(() -> pluginService.enablePlugin(plugin));
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

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

nativeDiscoveryToggleButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
Plugin plugin = pluginProperty.get();
if (plugin != null && plugin.getFootprint() != null) {
plugin.getFootprint().setNativeDiscoveryEnabled(newValue);
pluginService.save(plugin.getFootprint());
CompletableFuture.runAsync(() -> pluginService.save(plugin.getFootprint()));
}
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

}

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

public void refresh() {

Plugin plugin = pluginProperty.get();
if (plugin == null) {
return;
}
Expand Down Expand Up @@ -202,6 +205,7 @@ public void refresh() {
}

private void setPluginImage() {
Plugin plugin = pluginProperty.get();
String url = plugin.getScreenshotUrl();
if (url == null || url.isEmpty()) {
// Fallback to footprint screenshot URL
Expand Down Expand Up @@ -235,6 +239,7 @@ private void setPluginImage() {
}

private void showUninstallDialog() {
Plugin plugin = pluginProperty.get();

Dialog dialog = this.getDialogManager().newDialog();
DialogLayout layout = new DialogLayout();
Expand Down Expand Up @@ -263,9 +268,14 @@ private void showUninstallDialog() {
dialog.setContent(layout);
dialog.show();
}

@EventListener
private void handle(PluginRefreshEvent event) {
FX.run(this::refresh);
}

public ObjectProperty<Plugin> pluginProperty() {
return pluginProperty;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.owlplug.plugin.services.PluginService;
import com.owlplug.plugin.ui.PluginStateView;
import java.io.File;
import java.util.concurrent.CompletableFuture;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
Expand Down Expand Up @@ -230,7 +231,7 @@ private ContextMenu createPluginContextMenu(Plugin plugin) {
if (plugin.isDisabled()) {
MenuItem enableItem = new MenuItem("Enable plugin");
enableItem.setOnAction(e -> {
pluginService.enablePlugin(plugin);
CompletableFuture.runAsync(() -> pluginService.enablePlugin(plugin));
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
menu.getItems().add(enableItem);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.owlplug.plugin.model.Plugin;
import com.owlplug.plugin.repositories.PluginRepository;
import com.owlplug.plugin.services.PluginService;
import java.util.concurrent.CompletableFuture;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
Expand Down Expand Up @@ -205,9 +206,11 @@ public void initialize() {
}

public void displayPlugins() {
Iterable<Plugin> plugins = pluginRepository.findAll();
treeViewController.setPlugins(plugins);
tableController.setPlugins(plugins);
CompletableFuture.supplyAsync(() -> pluginRepository.findAll())
.thenAccept(plugins -> FX.run(() -> {
treeViewController.setPlugins(plugins);
tableController.setPlugins(plugins);
}));
Comment thread
DropSnorz marked this conversation as resolved.
}

public void selectPluginById(long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.owlplug.plugin.tasks.SymlinkRemoveTask;
import com.owlplug.plugin.ui.PluginListCellFactory;
import java.util.Optional;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -55,21 +57,22 @@ public class SymlinkInfoController extends BaseController {
@FXML
private Label targetPathLabel;

private Symlink symlink;
private final ObjectProperty<Symlink> symlinkProperty = new SimpleObjectProperty<>();

/**
* FXML Initialize.
*/
public void initialize() {

symlinkProperty.addListener(e -> refresh());
openLinkButton.setGraphic(new ImageView(this.getApplicationDefaults().symlinkImage));
openLinkButton.setOnAction(e -> {
PlatformUtils.openFromDesktop(symlink.getPath());
PlatformUtils.openFromDesktop(symlinkProperty.get().getPath());
});

openTargetButton.setGraphic(new ImageView(this.getApplicationDefaults().directoryImage));
openTargetButton.setOnAction(e -> {
PlatformUtils.openFromDesktop(symlink.getTargetPath());
PlatformUtils.openFromDesktop(symlinkProperty.get().getTargetPath());
});

pluginDirectoryListView.setCellFactory(new PluginListCellFactory(this.getApplicationDefaults()));
Expand All @@ -79,7 +82,7 @@ public void initialize() {
DialogLayout layout = new DialogLayout();

layout.setHeading(new Label("Remove directory"));
layout.setBody(new Label("Do you really want to delete link " + symlink.getName()
layout.setBody(new Label("Do you really want to delete link " + symlinkProperty.get().getName()
+ " ? Content will NOT be removed from the target folder."));

Button cancelButton = new Button("Cancel");
Expand All @@ -91,7 +94,7 @@ public void initialize() {
Button removeButton = new Button("Delete");
removeButton.setOnAction(removeEvent -> {
dialog.close();
taskFactory.create(new SymlinkRemoveTask(symlink))
taskFactory.create(new SymlinkRemoveTask(symlinkProperty.get()))
.setOnSucceeded(x -> taskFactory.createPluginScanTask().scheduleNow()).schedule();
});
removeButton.getStyleClass().add("button-danger");
Expand All @@ -102,13 +105,15 @@ public void initialize() {
});
}

public void setSymlink(Symlink symlink) {
this.symlink = symlink;
public void refresh() {
Symlink symlink = symlinkProperty.get();
directoryPathLabel.setText(symlink.getPath());
pluginDirectoryListView.getItems().setAll(symlink.getPluginList());
targetPathLabel.setText(Optional.ofNullable(symlink.getTargetPath()).orElse("Unknown"));

openTargetButton.setVisible(symlink.getTargetPath() != null);
}
Comment thread
DropSnorz marked this conversation as resolved.

public ObjectProperty<Symlink> symlinkProperty() {
return symlinkProperty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ public void enablePlugin(Plugin plugin) {

public PluginState getPluginState(Plugin plugin) {

if (!plugin.isScanComplete()) {
return PluginState.UNSTABLE;
}
if (plugin.isDisabled()) {
return PluginState.DISABLED;
}
if (!plugin.isScanComplete()) {
return PluginState.UNSTABLE;
}
if (plugin.isNativeCompatible()) {
return PluginState.ACTIVE;
}
Expand Down
Loading