use of com.biglybt.ui.swt.config.plugins.PluginParameter in project BiglyBT by BiglySoftware.
the class ConfigSectionPlugins method initPluginSubSections.
public void initPluginSubSections() {
// Create subsections for plugins that used the PluginConfigModel object
// =====================================================================
TreeItem treePlugins = configView.findTreeItem(ConfigSection.SECTION_PLUGINS);
ParameterRepository repository = ParameterRepository.getInstance();
String[] names = repository.getNames();
Arrays.sort(names);
for (int i = 0; i < names.length; i++) {
String pluginName = names[i];
Parameter[] parameters = repository.getParameterBlock(pluginName);
// Note: 2070's plugin documentation for PluginInterface.addConfigUIParameters
// said to pass <"ConfigView.plugins." + displayName>. This was
// never implemented in 2070. 2070 read the key <displayName> without
// the prefix.
//
// 2071+ uses <sSectionPrefix ("ConfigView.section.plugins.") + pluginName>
// and falls back to <displayName>. Since
// <"ConfigView.plugins." + displayName> was never implemented in the
// first place, a check for it has not been created
boolean bUsePrefix = MessageText.keyExists(ConfigView.sSectionPrefix + "plugins." + pluginName);
Composite pluginGroup = configView.createConfigSection(treePlugins, pluginName, -2, bUsePrefix);
GridLayout pluginLayout = new GridLayout();
pluginLayout.numColumns = 3;
pluginGroup.setLayout(pluginLayout);
Map parameterToPluginParameter = new HashMap();
// Add all parameters
for (int j = 0; j < parameters.length; j++) {
Parameter parameter = parameters[j];
parameterToPluginParameter.put(parameter, new PluginParameter(pluginGroup, parameter));
}
// Check for dependencies
for (int j = 0; j < parameters.length; j++) {
Parameter parameter = parameters[j];
if (parameter instanceof BooleanParameterImpl) {
List parametersToEnable = ((BooleanParameterImpl) parameter).getEnabledOnSelectionParameters();
List controlsToEnable = new ArrayList();
Iterator iter = parametersToEnable.iterator();
while (iter.hasNext()) {
Parameter parameterToEnable = (Parameter) iter.next();
PluginParameter pp = (PluginParameter) parameterToPluginParameter.get(parameterToEnable);
Control[] controls = pp.getControls();
Collections.addAll(controlsToEnable, controls);
}
List parametersToDisable = ((BooleanParameterImpl) parameter).getDisabledOnSelectionParameters();
List controlsToDisable = new ArrayList();
iter = parametersToDisable.iterator();
while (iter.hasNext()) {
Parameter parameterToDisable = (Parameter) iter.next();
PluginParameter pp = (PluginParameter) parameterToPluginParameter.get(parameterToDisable);
Control[] controls = pp.getControls();
Collections.addAll(controlsToDisable, controls);
}
Control[] ce = new Control[controlsToEnable.size()];
Control[] cd = new Control[controlsToDisable.size()];
if (ce.length + cd.length > 0) {
IAdditionalActionPerformer ap = new DualChangeSelectionActionPerformer((Control[]) controlsToEnable.toArray(ce), (Control[]) controlsToDisable.toArray(cd));
PluginParameter pp = (PluginParameter) parameterToPluginParameter.get(parameter);
pp.setAdditionalActionPerfomer(ap);
}
}
}
}
}
Aggregations