*/
public void createControl( Composite parent )
{
super.createControl( parent );
final TreeViewer treeViewer = getTreeViewer();
treeViewer.setLabelProvider( new LdifLabelProvider() );
treeViewer.setContentProvider( new LdifContentProvider() );
// treeViewer.setAutoExpandLevel(1);
treeViewer.addSelectionChangedListener( new ISelectionChangedListener()
{
public void selectionChanged( SelectionChangedEvent event )
{
if ( !event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection )
{
Object element = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
if ( element instanceof LdifRecord )
{
LdifRecord ldifRecord = ( LdifRecord ) element;
ldifEditor.selectAndReveal( ldifRecord.getDnLine().getOffset(), ldifRecord.getDnLine()
.getLength() );
}
else if ( element instanceof List )
{
List list = ( List ) element;
if ( !list.isEmpty() && list.get( 0 ) instanceof LdifAttrValLine )
{
LdifAttrValLine line = ( LdifAttrValLine ) list.get( 0 );
ldifEditor.selectAndReveal( line.getOffset(), line.getRawAttributeDescription().length() );
}
}
else if ( element instanceof LdifAttrValLine )
{
LdifAttrValLine line = ( LdifAttrValLine ) element;
ldifEditor.selectAndReveal( line.getOffset() + line.getRawAttributeDescription().length()
+ line.getRawValueType().length(), line.getRawValue().length() );
}
else if ( element instanceof LdifModSpec )
{
LdifModSpec modSpec = ( LdifModSpec ) element;
ldifEditor.selectAndReveal( modSpec.getOffset(), modSpec.getModSpecType().getLength() );
}
}
}
} );
treeViewer.addDoubleClickListener( new IDoubleClickListener()
{
public void doubleClick( DoubleClickEvent event )
{
if ( event.getSelection() instanceof IStructuredSelection )
{
Object obj = ( ( IStructuredSelection ) event.getSelection() ).getFirstElement();
if ( treeViewer.getExpandedState( obj ) )
treeViewer.collapseToLevel( obj, 1 );
else if ( ( ( ITreeContentProvider ) treeViewer.getContentProvider() ).hasChildren( obj ) )
treeViewer.expandToLevel( obj, 1 );
}
}
} );
this.refresh();