1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 15:30:09 -08:00

Rescan the plugins folder.

This commit is contained in:
Danila Fedorin 2017-08-09 11:02:21 -07:00
parent b99ad5a09a
commit 5e3daaed43
2 changed files with 15 additions and 7 deletions

View File

@ -255,13 +255,7 @@ public class AbacusController implements PluginListener {
abacus = new Abacus(new Configuration(CONFIG_FILE)); abacus = new Abacus(new Configuration(CONFIG_FILE));
PluginManager abacusPluginManager = abacus.getPluginManager(); PluginManager abacusPluginManager = abacus.getPluginManager();
abacusPluginManager.addListener(this); abacusPluginManager.addListener(this);
abacusPluginManager.addInstantiated(new StandardPlugin(abacus.getPluginManager())); performScan();
try {
ClassFinder.loadJars("plugins").forEach(abacusPluginManager::addClass);
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
abacusPluginManager.reload();
computationLimitField.setText(Double.toString(abacus.getConfiguration().getComputationDelay())); computationLimitField.setText(Double.toString(abacus.getConfiguration().getComputationDelay()));
computationLimitField.textProperty().addListener((observable, oldValue, newValue) -> { computationLimitField.textProperty().addListener((observable, oldValue, newValue) -> {
@ -311,6 +305,19 @@ public class AbacusController implements PluginListener {
reloadAlertShown = false; reloadAlertShown = false;
} }
@FXML
public void performScan(){
PluginManager abacusPluginManager = abacus.getPluginManager();
abacusPluginManager.removeAll();
abacusPluginManager.addInstantiated(new StandardPlugin(abacus.getPluginManager()));
try {
ClassFinder.loadJars("plugins").forEach(abacusPluginManager::addClass);
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
abacusPluginManager.reload();
}
@FXML @FXML
public void performReload() { public void performReload() {
alertIfApplyNeeded(true); alertIfApplyNeeded(true);

View File

@ -57,6 +57,7 @@
<Button text="Apply" onAction="#performSave"/> <Button text="Apply" onAction="#performSave"/>
<Button text="Reload Plugins" onAction="#performReload"/> <Button text="Reload Plugins" onAction="#performReload"/>
<Button text="Apply and Reload" onAction="#performSaveAndReload"/> <Button text="Apply and Reload" onAction="#performSaveAndReload"/>
<Button text="Scan Plugins" onAction="#performScan"/>
</FlowPane> </FlowPane>
</GridPane> </GridPane>
</Tab> </Tab>