public void configurationChanged(ConfigurationChangeEvent ev)
{
ArrayList<AttributeSyntax<?>> newSyntaxes =
new ArrayList<AttributeSyntax<?>>();
final ServerDescriptor desc = ev.getNewDescriptor();
Schema s = desc.getSchema();
boolean schemaChanged;
if (schema != null && s != null)
{
schemaChanged = !ServerDescriptor.areSchemasEqual(s, schema);
}
else if (schema == null && s != null)
{
schemaChanged = true;
}
else if (s == null && schema != null)
{
schemaChanged = false;
}
else
{
schemaChanged = false;
}
if (schemaChanged)
{
schema = s;
HashMap<String, AttributeSyntax<?>> syntaxNameMap = new HashMap<String,
AttributeSyntax<?>>();
for (String key : schema.getSyntaxes().keySet())
{
AttributeSyntax<?> syntax = schema.getSyntax(key);
String name = syntax.getSyntaxName();
if (name == null)
{
name = syntax.getOID();
}
syntaxNameMap.put(name, syntax);
}
SortedSet<String> orderedKeys =
new TreeSet<String>(new LowerCaseComparator());
orderedKeys.addAll(syntaxNameMap.keySet());
for (String key : orderedKeys)
{
newSyntaxes.add(syntaxNameMap.get(key));
}
updateComboBoxModel(newSyntaxes,
((DefaultComboBoxModel)syntax.getModel()));
HashMap<String, AttributeType> attributeNameMap = new HashMap<String,
AttributeType>();
for (String key : schema.getAttributeTypes().keySet())
{
AttributeType attr = schema.getAttributeType(key);
attributeNameMap.put(attr.getNameOrOID(), attr);
}
orderedKeys.clear();
orderedKeys.addAll(attributeNameMap.keySet());
ArrayList<Object> newParents = new ArrayList<Object>();
for (String key : orderedKeys)
{
newParents.add(attributeNameMap.get(key));
}
newParents.add(0, NO_PARENT);
updateComboBoxModel(newParents,
((DefaultComboBoxModel)parent.getModel()));
ArrayList<MatchingRule> approximateElements =
new ArrayList<MatchingRule>();
ArrayList<MatchingRule> equalityElements = new ArrayList<MatchingRule>();
ArrayList<MatchingRule> orderingElements = new ArrayList<MatchingRule>();
ArrayList<MatchingRule> substringElements = new ArrayList<MatchingRule>();
HashMap<String, MatchingRule> matchingRuleNameMap = new HashMap<String,
MatchingRule>();
for (String key : schema.getMatchingRules().keySet())
{
MatchingRule rule = schema.getMatchingRule(key);
matchingRuleNameMap.put(rule.getNameOrOID(), rule);
}
orderedKeys.clear();
orderedKeys.addAll(matchingRuleNameMap.keySet());
for (String key : orderedKeys)
{
MatchingRule matchingRule = matchingRuleNameMap.get(key);
if (matchingRule instanceof ApproximateMatchingRule)
{
approximateElements.add(matchingRule);
}
else if (matchingRule instanceof EqualityMatchingRule)
{
equalityElements.add(matchingRule);
}
else if (matchingRule instanceof OrderingMatchingRule)
{
orderingElements.add(matchingRule);
}
else if (matchingRule instanceof SubstringMatchingRule)
{
substringElements.add(matchingRule);
}
}
JComboBox[] combos = {approximate, equality, ordering, substring};
ArrayList<ArrayList<MatchingRule>> ruleNames =
new ArrayList<ArrayList<MatchingRule>>();
ruleNames.add(approximateElements);
ruleNames.add(equalityElements);
ruleNames.add(orderingElements);
ruleNames.add(substringElements);
for (int i=0; i<combos.length; i++)
{
DefaultComboBoxModel model = (DefaultComboBoxModel)combos[i].getModel();
ArrayList<Object> el = new ArrayList<Object>();
el.addAll(ruleNames.get(i));
if (model.getSize() == 0)
{
el.add(0, NO_MATCHING_RULE);
}
else
{
el.add(0, model.getElementAt(0));
}
updateComboBoxModel(el, model);
}
}
else if (schema == null)
{
updateErrorPane(errorPane,
ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(),
ColorAndFontConstants.errorTitleFont,
ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(),
ColorAndFontConstants.defaultFont);
}
if (schema != null)
{
updateErrorPaneIfAuthRequired(desc,
isLocal() ?
INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_ATTRIBUTE_DELETE.get() :
INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
}
SwingUtilities.invokeLater(new Runnable()
{
/**
* {@inheritDoc}