configpanel: various fixes (#2774)
* configpanel: ensure enums are properly displayed * configpanel: properly categorize buttons. * configpanel: remove unnecessary button array.
This commit is contained in:
@@ -440,8 +440,6 @@ class ConfigPanel extends PluginPanel
|
|||||||
ConfigDescriptor cd = pluginConfig.getConfigDescriptor();
|
ConfigDescriptor cd = pluginConfig.getConfigDescriptor();
|
||||||
assert cd != null;
|
assert cd != null;
|
||||||
|
|
||||||
List<JButton> buttons = new ArrayList<>();
|
|
||||||
|
|
||||||
Map<String, Map<String, String>> pluginsInfoMap = externalPluginManager.getPluginsInfoMap();
|
Map<String, Map<String, String>> pluginsInfoMap = externalPluginManager.getPluginsInfoMap();
|
||||||
|
|
||||||
if (pluginConfig.getPlugin() != null && pluginsInfoMap.containsKey(pluginConfig.getPlugin().getClass().getSimpleName()))
|
if (pluginConfig.getPlugin() != null && pluginsInfoMap.containsKey(pluginConfig.getPlugin().getClass().getSimpleName()))
|
||||||
@@ -566,28 +564,6 @@ class ConfigPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cid.getType() == Button.class)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ConfigItem item = cid.getItem();
|
|
||||||
JButton button = new JButton(item.name());
|
|
||||||
button.addActionListener((e) -> {
|
|
||||||
ConfigButtonClicked event = new ConfigButtonClicked();
|
|
||||||
event.setGroup(cd.getGroup().value());
|
|
||||||
event.setKey(cid.getItem().keyName());
|
|
||||||
eventBus.post(ConfigButtonClicked.class, event);
|
|
||||||
});
|
|
||||||
buttons.add(button);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
log.error("Adding action listener failed: {}", ex.getMessage());
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
JPanel item = new JPanel();
|
JPanel item = new JPanel();
|
||||||
item.setLayout(new BorderLayout());
|
item.setLayout(new BorderLayout());
|
||||||
item.setMinimumSize(new Dimension(PANEL_WIDTH, 0));
|
item.setMinimumSize(new Dimension(PANEL_WIDTH, 0));
|
||||||
@@ -597,6 +573,28 @@ class ConfigPanel extends PluginPanel
|
|||||||
configEntryName.setToolTipText("<html>" + name + ":<br>" + cid.getItem().description() + "</html>");
|
configEntryName.setToolTipText("<html>" + name + ":<br>" + cid.getItem().description() + "</html>");
|
||||||
item.add(configEntryName, cid.getType() != String.class ? BorderLayout.CENTER : BorderLayout.NORTH);
|
item.add(configEntryName, cid.getType() != String.class ? BorderLayout.CENTER : BorderLayout.NORTH);
|
||||||
|
|
||||||
|
if (cid.getType() == Button.class)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ConfigItem cidItem = cid.getItem();
|
||||||
|
JButton button = new JButton(cidItem.name());
|
||||||
|
button.addActionListener((e) ->
|
||||||
|
{
|
||||||
|
ConfigButtonClicked event = new ConfigButtonClicked();
|
||||||
|
event.setGroup(cd.getGroup().value());
|
||||||
|
event.setKey(cid.getItem().keyName());
|
||||||
|
eventBus.post(ConfigButtonClicked.class, event);
|
||||||
|
});
|
||||||
|
item.add(button);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.error("Adding action listener failed: {}", ex.getMessage());
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cid.getType() == boolean.class)
|
if (cid.getType() == boolean.class)
|
||||||
{
|
{
|
||||||
JCheckBox checkbox = new JCheckBox();
|
JCheckBox checkbox = new JCheckBox();
|
||||||
@@ -612,7 +610,8 @@ class ConfigPanel extends PluginPanel
|
|||||||
item.remove(configEntryName);
|
item.remove(configEntryName);
|
||||||
|
|
||||||
JButton button = new JButton(cid.getItem().name());
|
JButton button = new JButton(cid.getItem().name());
|
||||||
button.addActionListener((e) -> {
|
button.addActionListener((e) ->
|
||||||
|
{
|
||||||
log.debug("Running consumer: {}.{}", cd.getGroup().value(), cid.getItem().keyName());
|
log.debug("Running consumer: {}.{}", cd.getGroup().value(), cid.getItem().keyName());
|
||||||
configManager.getConsumer(cd.getGroup().value(), cid.getItem().keyName()).accept(pluginConfig.getPlugin());
|
configManager.getConsumer(cd.getGroup().value(), cid.getItem().keyName()).accept(pluginConfig.getPlugin());
|
||||||
});
|
});
|
||||||
@@ -945,7 +944,7 @@ class ConfigPanel extends PluginPanel
|
|||||||
box.setToolTipText(Text.titleCase((Enum) box.getSelectedItem()));
|
box.setToolTipText(Text.titleCase((Enum) box.getSelectedItem()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
item.add(box, BorderLayout.CENTER);
|
item.add(box, BorderLayout.EAST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cid.getType() == Keybind.class || cid.getType() == ModifierlessKeybind.class)
|
if (cid.getType() == Keybind.class || cid.getType() == ModifierlessKeybind.class)
|
||||||
@@ -1015,8 +1014,6 @@ class ConfigPanel extends PluginPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons.forEach(mainPanel::add);
|
|
||||||
|
|
||||||
JButton resetButton = new JButton("Reset");
|
JButton resetButton = new JButton("Reset");
|
||||||
resetButton.addActionListener((e) ->
|
resetButton.addActionListener((e) ->
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user