diff --git a/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/src/main/java/org/nwapw/abacus/fx/AbacusController.java index 7c3d6b7..5597784 100644 --- a/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -216,7 +216,7 @@ public class AbacusController implements PluginListener { Callback, TableCell> cellFactory = param -> new CopyableCell<>(); Callback, ListCell> pluginCellFactory = - param -> new CheckBoxListCell<>(ToggleablePlugin::enabledProperty, new StringConverter() { + param -> new CheckBoxListCell<>(ToggleablePlugin::getEnabledProperty, new StringConverter() { @Override public String toString(ToggleablePlugin object) { return object.getClassName().substring(object.getClassName().lastIndexOf('.') + 1); @@ -224,7 +224,7 @@ public class AbacusController implements PluginListener { @Override public ToggleablePlugin fromString(String string) { - return new ToggleablePlugin(true, string); + return new ToggleablePlugin(string, true); } }); @@ -343,8 +343,8 @@ public class AbacusController implements PluginListener { numberImplementationBox.getSelectionModel().select(toSelect); for (Class pluginClass : abacus.getPluginManager().getLoadedPluginClasses()) { String fullName = pluginClass.getName(); - ToggleablePlugin plugin = new ToggleablePlugin(!disabledPlugins.contains(fullName), fullName); - plugin.enabledProperty().addListener(e -> changesMade = true); + ToggleablePlugin plugin = new ToggleablePlugin(fullName, !disabledPlugins.contains(fullName)); + plugin.getEnabledProperty().addListener(e -> changesMade = true); enabledPlugins.add(plugin); } functionList.addAll(manager.getAllFunctions()); diff --git a/src/main/java/org/nwapw/abacus/fx/ToggleablePlugin.java b/src/main/java/org/nwapw/abacus/fx/ToggleablePlugin.java deleted file mode 100644 index 0a87571..0000000 --- a/src/main/java/org/nwapw/abacus/fx/ToggleablePlugin.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.nwapw.abacus.fx; - -import javafx.beans.property.BooleanProperty; -import javafx.beans.property.SimpleBooleanProperty; - -/** - * Class that represents an entry in the plugin check box list. - * The changes from this property are written to the config on application. - */ -public class ToggleablePlugin { - - /** - * The property that determines whether the plugin will be enabled. - */ - private final BooleanProperty enabled; - /** - * The name of the class this entry toggles. - */ - private final String className; - - /** - * Creates a new toggleable plugin with the given properties. - * - * @param enabled the enabled / disabled state at the beginning. - * @param className the name of the class this plugin toggles. - */ - public ToggleablePlugin(boolean enabled, String className) { - this.enabled = new SimpleBooleanProperty(); - this.enabled.setValue(enabled); - this.className = className; - } - - /** - * Gets the enabled property of this plugin. - * - * @return the enabled property. - */ - public BooleanProperty enabledProperty() { - return enabled; - } - - /** - * Checks if this plugin entry should be enabled. - * - * @return whether this plugin will be enabled. - */ - public boolean isEnabled() { - return enabled.get(); - } - - /** - * Gets the class name this plugin toggles. - * - * @return the class name that should be disabled. - */ - public String getClassName() { - return className; - } - -} diff --git a/src/main/kotlin/org/nwapw/abacus/fx/ToggleablePlugin.kt b/src/main/kotlin/org/nwapw/abacus/fx/ToggleablePlugin.kt new file mode 100644 index 0000000..b575217 --- /dev/null +++ b/src/main/kotlin/org/nwapw/abacus/fx/ToggleablePlugin.kt @@ -0,0 +1,13 @@ +package org.nwapw.abacus.fx + +import javafx.beans.property.SimpleBooleanProperty + +class ToggleablePlugin (val className: String, enabled: Boolean) { + + val enabledProperty = SimpleBooleanProperty(enabled) + + fun isEnabled(): Boolean { + return enabledProperty.value + } + +} \ No newline at end of file