Hiding and unhiding

This commit is contained in:
Scott Burns
2019-05-20 19:50:40 +02:00
parent 888ac75b18
commit 05028d4035
2 changed files with 37 additions and 0 deletions

View File

@@ -49,5 +49,7 @@ public @interface ConfigItem
String group() default "";
String unhide() default "";
String parent() default "";
}

View File

@@ -505,6 +505,29 @@ public class ConfigPanel extends PluginPanel
continue; // Ignore main 'parent'
}
if (cid.getItem().hidden())
{
boolean show = false;
String unhideat = cid.getItem().unhide();
for (ConfigItemDescriptor cid2 : cd.getItems())
{
if (cid2.getItem().keyName().equals(unhideat))
{
if (cid2.getType() == boolean.class)
{
show = Boolean.parseBoolean(configManager.getConfiguration(cd.getGroup().value(), cid2.getItem().keyName()));
}
}
}
if (!show)
{
continue;
}
}
JPanel item = new JPanel();
item.setLayout(new BorderLayout());
item.setMinimumSize(new Dimension(PANEL_WIDTH, 0));
@@ -821,6 +844,18 @@ public class ConfigPanel extends PluginPanel
{
JCheckBox checkbox = (JCheckBox) component;
configManager.setConfiguration(cd.getGroup().value(), cid.getItem().keyName(), "" + checkbox.isSelected());
for (ConfigItemDescriptor cid2 : cd.getItems())
{
if (cid2.getItem().hidden())
{
if (cid2.getItem().unhide().equals(cid.getItem().keyName()))
{ // If another options visibility changes depending on the value of this checkbox, then render the entire menu again
openGroupConfigPanel(listItem, config, cd);
return;
}
}
}
}
else if (component instanceof JSpinner)
{