/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
*/
/**
* Abstract class used to re-factor some code between the classes that are used
*
*/
{
/**
* Title panel.
*/
/**
* Name label.
*/
/**
* Base DN label.
*/
/**
* Search scope label.
*/
/**
* Search filter label.
*/
/**
* Sort order label.
*/
/**
* Backends label.
*/
/**
* Max block size label.
*/
/**
* Name text field.
*/
/**
* Read-only name label.
*/
/**
* Read-only backend name label.
*/
/**
* Base DNs combo box.
*/
/**
* Subtree text field.
*/
/**
* Base Object scope radio button.
*/
/**
* Single Level scope radio button.
*/
/**
* Subordinate subtree scope radio button.
*/
/**
* Whole subtree scope radio button.
*/
/**
* Filter text field.
*/
/**
* Max block size text field.
*/
/**
* Attributes combo box.
*/
/**
* The list containing the sort order elements.
*/
/**
* The add button.
*/
/**
* The move up button.
*/
/**
* The move down button.
*/
/**
* The remove button.
*/
/**
* Ascending order combo box.
*/
/**
* Combo box containing the sort order.
*/
/**
* The list of labels.
*/
/**
* The relative component that must be used to center the parent dialog of
* this panel.
*/
/**
* Other base DN message.
*/
/**
* Ascending message.
*/
/**
* Descending message.
*/
/**
* Custom attributes message.
*/
/**
* Standard attributes message.
*/
/**
* The list of standard attribute names.
*/
/**
* The list of configuration attribute names.
*/
/**
* The list of custom attribute names.
*/
private int defaultVLVEntryLimitValue;
{
}
/**
* Minimum value for max block size.
*/
protected final int MIN_MAX_BLOCK_SIZE =
/**
* Maximum value for max block size.
*/
/**
* Default value for max block size.
*/
/**
* Constructor.
* @param backendID the backend ID where the index is defined (or will be
* defined).
* @param relativeComponent the relative component where the dialog containing
* this panel must be centered.
*/
{
super();
{
}
this.relativeComponent = relativeComponent;
}
/**
* Sets the name of the backend where the index is defined or will be defined.
* @param backendID the ID of the backend.
*/
{
}
/**
* Returns the LDIF representing the new index.
* @param indexName the name of the index.
* @return the LDIF representing the new index.
*/
{
",cn=VLV Index,"+dn);
{
}
}
/**
* Returns the scope of the VLV index as it appears on the panel.
* @return the scope of the VLV index as it appears on the panel.
*/
{
if (baseObject.isSelected())
{
}
else if (singleLevel.isSelected())
{
}
else if (subordinateSubtree.isSelected())
{
}
else
{
}
return scope;
}
/**
* Returns the list of VLV sort order elements as they are displayed in the
* panel.
* @return the list of VLV sort order elements as they are displayed in the
* panel.
*/
{
{
}
return sortOrder;
}
/**
* Returns the string representation for the provided list of VLV sort order.
* @param sortOrder the list of VLV sort order elements.
* @return the string representation for the provided list of VLV sort order.
*/
{
for (VLVSortOrder s : sortOrder)
{
{
}
if (s.isAscending())
{
}
else
{
}
}
}
/**
* Updates the layout with the provided server descriptor.
* @param desc the server descriptor.
* @return <CODE>true</CODE> if an error has been displayed and
* <CODE>false</CODE> otherwise.
*/
{
final boolean[] repack = {false};
final boolean[] error = {false};
{
}
{
synchronized(standardAttrNames)
{
{
boolean defined = false;
{
{
defined = true;
break;
}
}
if (!defined)
{
{
}
{
}
else
{
}
}
}
}
{
{
}
}
{
{
}
}
// 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));
}
}
*/
}
else
{
repack[0] = true;
error[0] = true;
}
{
public void run()
{
{
}
if (repack[0])
{
if (relativeComponent != null)
{
}
}
}
});
return !error[0];
}
/**
* Returns <CODE>true</CODE> if the user accepts to continue creating the VLV
* index even if no indexes are created for the provided filter for the VLV
* index. Returns <CODE>false</CODE> if the user does not accept to create
* the index. Note that the confirmation dialog will only be displayed when
* the indexes are not defined, if the dialog is not displayed the method
* returns <CODE>true</CODE>.
* @return <CODE>true</CODE> if the user accepts to continue creating the VLV
* index even if no indexes are created for the provided filter for the VLV
* index. Returns <CODE>false</CODE> if the user does not accept to create
* the index.
*/
protected boolean checkIndexRequired()
{
boolean confirm = true;
try
{
{
{
}
}
}
catch (Throwable t)
{
// Bug
throw new RuntimeException("Unexpected error: "+t, t);
}
return confirm;
}
/**
* Updates the provided list of error messages by analyzing the provided
* filter. The idea is basically to analyze the filter and check if what
* appears on the filter is indexed or not. If it is not indexed it updates
* the error message list with a message explaining that.
* @param filter the filter to analyze.
* @param msgs the list of messages to be updated.
*/
{
switch (filter.getFilterType())
{
case AND:
case OR:
{
{
}
}
break;
case NOT:
break;
default:
};
};
};
{
{
{
{
{
}
}
}
else
{
{
}
else
{
filter.getAttributeType()));
}
}
}
}
}
}
/**
* Returns the index descriptor for a given index name (<CODE>null</CODE> if
* no index descriptor is found for that name).
* @param indexName the name of the index.
* @return the index descriptor for a given index name.
*/
{
{
{
{
index = i;
break;
}
}
}
return index;
}
/**
* Updates the base DN combo box with the provided backend.
* @param backend the backend to be used with the provided backend.
*/
{
{
try
{
}
catch (Throwable t)
{
throw new RuntimeException("Unexpected error: "+t, t);
}
}
}
/**
* Updates a list of errors with the errors found in the panel.
* @param checkName whether the name of the VLV index must be checked or not.
* @return a list containing the error messages found.
*/
{
{
setPrimaryValid(l);
}
if (checkName)
{
{
}
{
// Check that there is no other VLV index with same name
{
{
backendName.getText()));
break;
}
}
}
}
{
}
else
{
try
{
}
catch (OpenDsException oe)
{
}
}
if (f.equals(""))
{
}
else
{
try
{
LDAPFilter.decode(f);
}
catch (LDAPException le)
{
}
}
{
}
try
{
if ((n < MIN_MAX_BLOCK_SIZE) || (n > MAX_MAX_BLOCK_SIZE))
{
}
}
catch (Throwable t)
{
}
return errors;
}
/**
* Returns the backend for the index.
* @return the backend for the index.
*/
{
// Check that the index does not exist
{
{
backend = b;
break;
}
}
return backend;
}
/**
* Returns the base DN for the VLV index.
* @return the base DN for the VLV index.
*/
{
{
}
if (selectedItem != null)
{
return selectedItem.toString();
}
else
{
return null;
}
}
/**
* Returns the selected attribute.
* @return the selected attribute.
*/
{
if (o != null)
{
}
else
{
}
return attrName;
}
/**
* Creates the basic layout of the panel.
* @param c the container of the layout.
* @param gbc the grid bag constraints to be used.
* @param nameReadOnly whether the panel is read-only or not.
*/
boolean nameReadOnly)
{
addErrorPane(c, gbc);
if (nameReadOnly)
{
}
if (nameReadOnly)
{
}
else
{
p.setOpaque(false);
}
p.setOpaque(false);
{
{
}
});
};
singleLevel.setSelected(true);
{
}
{
{
{
remove.setEnabled(true);
}
else
{
moveUp.setEnabled(false);
moveUp.setEnabled(false);
remove.setEnabled(false);
}
}
};
{
button.setEnabled(false);
}
{
{
{
int i = attributes.getSelectedIndex();
if (i > 0)
{
// To avoid issues, try to figure out first the new selection
int newIndex = -1;
{
model.getElementAt(j);
{
newIndex = j;
}
}
if (newIndex == -1)
{
{
model.getElementAt(j);
{
newIndex = j;
}
}
}
if (newIndex != -1)
{
}
model.removeElementAt(i);
}
}
}
});
{
{
{
}
}
});
{
{
{
}
}
});
{
{
synchronized (standardAttrNames)
{
{
indexes[i]);
boolean dealingWithCustom = true;
{
model.getElementAt(j);
{
if (dealingWithCustom == isCustom)
{
{
break;
}
}
}
{
dealingWithCustom = false;
if (isCustom)
{
break;
}
}
}
}
}
{
}
}
});
sortOrderModel = new DefaultListModel();
}
}