in plugins/openldap.config.editor/src/main/java/org/apache/directory/studio/openldap/config/editor/dialogs/DbIndexDialog.java [232:384]
public void widgetSelected( SelectionEvent e )
{
// Check that we aren't coming from a modification of the SUB button
DbIndexWrapper indexWrapper = getEditedElement();
Button button = (Button)e.getSource();
// First, update the indexTypes set
if ( button == subAnyCheckbox )
{
if ( button.getSelection() )
{
if ( subInitialCheckbox.getSelection() && subFinalCheckbox.getSelection() )
{
// The three subXXX indexes are selected : select the SUB checkbox
subCheckbox.setSelection( true );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBINITIAL );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBFINAL );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
else if ( subInitialCheckbox.getSelection() || subFinalCheckbox.getSelection() )
{
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBANY );
}
else
{
// Gray the sub checkbox, and select it
subCheckbox.setSelection( true );
subCheckbox.setGrayed( true );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
}
else
{
if ( !subInitialCheckbox.getSelection() && !subFinalCheckbox.getSelection() )
{
subCheckbox.setGrayed( false );
subCheckbox.setSelection( false );
}
else if ( subInitialCheckbox.getSelection() && subFinalCheckbox.getSelection() )
{
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBINITIAL );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBFINAL );
subCheckbox.setGrayed( true );
}
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
}
else if ( button == subInitialCheckbox )
{
if ( button.getSelection() )
{
if ( subAnyCheckbox.getSelection() && subFinalCheckbox.getSelection() )
{
// The three subXXX indexes are selected : select the SUB checkbox
subCheckbox.setSelection( true );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBINITIAL );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBFINAL );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
else if ( subAnyCheckbox.getSelection() || subFinalCheckbox.getSelection() )
{
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBINITIAL );
}
else
{
// Gray the sub checkbox, and select it
subCheckbox.setSelection( true );
subCheckbox.setGrayed( true );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
}
else
{
if ( !subAnyCheckbox.getSelection() && !subFinalCheckbox.getSelection() )
{
subCheckbox.setGrayed( false );
subCheckbox.setSelection( false );
}
else if ( subAnyCheckbox.getSelection() && subFinalCheckbox.getSelection() )
{
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBFINAL );
subCheckbox.setGrayed( true );
}
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBINITIAL );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
}
else if ( button == subFinalCheckbox )
{
if ( button.getSelection() )
{
if ( subAnyCheckbox.getSelection() && subInitialCheckbox.getSelection() )
{
// The three subXXX indexes are selected : select the SUB checkbox
subCheckbox.setSelection( true );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBINITIAL );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBFINAL );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
else if ( subAnyCheckbox.getSelection() || subInitialCheckbox.getSelection() )
{
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBFINAL );
}
else
{
// Gray the sub checkbox, and select it
subCheckbox.setSelection( true );
subCheckbox.setGrayed( true );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBFINAL );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
}
else
{
if ( !subAnyCheckbox.getSelection() && !subInitialCheckbox.getSelection() )
{
subCheckbox.setGrayed( false );
subCheckbox.setSelection( false );
}
else if ( subAnyCheckbox.getSelection() && subInitialCheckbox.getSelection() )
{
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBANY );
indexWrapper.getIndexTypes().add( DbIndexTypeEnum.SUBINITIAL );
subCheckbox.setGrayed( true );
}
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBFINAL );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUB );
indexWrapper.getIndexTypes().remove( DbIndexTypeEnum.SUBSTR );
}
}
// Last, update the subCheckbox state
checkAndUpdateOkButtonEnableState();
}