/**
* {@inheritDoc}
*/
public void configurationChanged(ConfigurationChangeEvent ev)
{
final ServerDescriptor desc = ev.getNewDescriptor();
Schema s = desc.getSchema();
final boolean[] repack = {false};
final boolean[] error = {false};
if (s != null)
{
schema = s;
repack[0] = attributes.getItemCount() == 0;
LinkedHashSet<CategorizedComboBoxElement> newElements =
new LinkedHashSet<CategorizedComboBoxElement>();
// Check that the index does not exist
BackendDescriptor backend = null;
for (BackendDescriptor b : getInfo().getServerDescriptor().getBackends())
{
if (b.getBackendID().equalsIgnoreCase(backendName.getText()))
{
backend = b;
break;
}
}
TreeSet<String> standardAttrNames = new TreeSet<String>();
TreeSet<String> configurationAttrNames = new TreeSet<String>();
TreeSet<String> customAttrNames = new TreeSet<String>();
for (AttributeType attr : schema.getAttributeTypes().values())
{
String name = attr.getPrimaryName();
boolean defined = false;
if (backend != null)
{
for (IndexDescriptor index : backend.getIndexes())
{
if (index.getName().equalsIgnoreCase(name))
{
defined = true;
break;
}
}
}
if (!defined)
{
if (Utilities.isStandard(attr))
{
standardAttrNames.add(name);
}
else if (Utilities.isConfiguration(attr))
{
configurationAttrNames.add(name);
}
else
{
customAttrNames.add(name);
}
}
}
if (customAttrNames.size() > 0)
{
newElements.add(new CategorizedComboBoxElement(
CUSTOM_ATTRIBUTES,
CategorizedComboBoxElement.Type.CATEGORY));
for (String attrName : customAttrNames)
{
newElements.add(new CategorizedComboBoxElement(
attrName,
CategorizedComboBoxElement.Type.REGULAR));
}
}
if (standardAttrNames.size() > 0)
{
newElements.add(new CategorizedComboBoxElement(
STANDARD_ATTRIBUTES,
CategorizedComboBoxElement.Type.CATEGORY));
for (String attrName : standardAttrNames)
{
newElements.add(new CategorizedComboBoxElement(
attrName,
CategorizedComboBoxElement.Type.REGULAR));
}
}
// Ignore configuration attr names
/*
if (configurationAttrNames.size() > 0)
{
newElements.add(new CategorizedComboBoxDescriptor(
"Configuration Attributes",
CategorizedComboBoxDescriptor.Type.CATEGORY));
for (String attrName : configurationAttrNames)
{
newElements.add(new CategorizedComboBoxDescriptor(
attrName,
CategorizedComboBoxDescriptor.Type.REGULAR));
}
}
*/
DefaultComboBoxModel model =
(DefaultComboBoxModel)attributes.getModel();
updateComboBoxModel(newElements, model);
}
else
{
updateErrorPane(errorPane,
ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_SUMMARY.get(),
ColorAndFontConstants.errorTitleFont,
ERR_CTRL_PANEL_SCHEMA_NOT_FOUND_DETAILS.get(),
ColorAndFontConstants.defaultFont);
repack[0] = true;
error[0] = true;
}
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
setEnabledOK(!error[0]);
errorPane.setVisible(error[0]);
if (repack[0])
{
packParentDialog();
if (relativeComponent != null)
{
Utilities.centerGoldenMean(
Utilities.getParentDialog(NewIndexPanel.this),
relativeComponent);
}
}
}
});
if (!error[0])
{
updateErrorPaneAndOKButtonIfAuthRequired(desc,
isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_INDEX.get() :
INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
}
}