use of net.runelite.client.plugins.PluginInstantiationException in project runelite by runelite.
the class ConfigPanel method buildToggleButton.
private JButton buildToggleButton(Plugin plugin) {
// Create enabling/disabling button
final JButton toggleButton = new JButton(new ImageIcon(CHECK_ICON));
toggleButton.setPreferredSize(new Dimension(32, 0));
if (plugin == null) {
toggleButton.setEnabled(false);
return toggleButton;
}
highlightButton(toggleButton, pluginManager.isPluginEnabled(plugin));
toggleButton.addActionListener(e -> executorService.submit(() -> {
final boolean enabled = pluginManager.isPluginEnabled(plugin);
pluginManager.setPluginEnabled(plugin, !enabled);
try {
if (enabled) {
pluginManager.stopPlugin(plugin);
} else {
pluginManager.startPlugin(plugin);
}
} catch (PluginInstantiationException ex) {
log.warn("Error during starting/stopping plugin {}", plugin.getClass().getSimpleName(), ex);
}
highlightButton(toggleButton, !enabled);
}));
return toggleButton;
}
Aggregations