}
}
}
else if ( editorPart instanceof EntryEditor )
{
EntryEditor entryEditor = ( EntryEditor ) editorPart;
if ( !event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection )
{
Object o = entryEditor.getMainWidget().getViewer().getInput();
if ( o != null && o instanceof IEntry )
{
IEntry entry = ( IEntry ) o;
IAttribute[] attributes = entry.getAttributes();
List selectionList = new ArrayList();
Iterator it = ( ( IStructuredSelection ) event.getSelection() ).iterator();
while ( it.hasNext() )
{
Object element = it.next();
if ( element instanceof LdifAttrValLine )
{
// select the value
LdifAttrValLine line = ( LdifAttrValLine ) element;
for ( int a = 0; a < attributes.length; a++ )
{
IAttribute attribute = attributes[a];
if ( attribute.getDescription().equals( line.getUnfoldedAttributeDescription() ) )
{
IValue[] values = attribute.getValues();
for ( int v = 0; v < values.length; v++ )
{
IValue value = values[v];
if ( value.getStringValue().equals( line.getValueAsString() ) )
{
selectionList.add( value );
}
}
}
}
}
else if ( element instanceof List )
{
// select attribute and all values
List list = ( List ) element;
if ( !list.isEmpty() && list.get( 0 ) instanceof LdifAttrValLine )
{
LdifAttrValLine line = ( LdifAttrValLine ) list.get( 0 );
for ( int a = 0; a < attributes.length; a++ )
{
IAttribute attribute = attributes[a];
if ( attribute.getDescription().equals(
line.getUnfoldedAttributeDescription() ) )
{
selectionList.add( attribute );
selectionList.addAll( Arrays.asList( attribute.getValues() ) );
}
}
}
}
else if ( element instanceof LdifRecord )
{
for ( int a = 0; a < attributes.length; a++ )
{
IAttribute attribute = attributes[a];
selectionList.add( attribute );
selectionList.addAll( Arrays.asList( attribute.getValues() ) );
}
}
}
IStructuredSelection selection = new StructuredSelection( selectionList );
entryEditor.getMainWidget().getViewer().setSelection( selection );
}
}
}
}
} );