LdifContainer[] containers = getSelectedLdifContainers();
if ( containers.length == 1
&& ( containers[0] instanceof LdifContentRecord || containers[0] instanceof LdifChangeAddRecord ) )
{
LdifContainer container = containers[0];
LdifEntryEditorDialog dialog = null;
if ( container instanceof LdifContentRecord )
{
dialog = new LdifEntryEditorDialog( editor.getEditorSite().getShell(), editor.getConnection(),
( LdifContentRecord ) container );
}
else
{
dialog = new LdifEntryEditorDialog( editor.getEditorSite().getShell(), editor.getConnection(),
( LdifChangeAddRecord ) container );
}
editor.deactivateGlobalActionHandlers();
if ( dialog.open() == LdifEntryEditorDialog.OK )
{
LdifRecord record = dialog.getLdifRecord();
IDocument document = editor.getDocumentProvider().getDocument( editor.getEditorInput() );
String old = document.get();
StringBuffer sb = new StringBuffer();
sb.append( old.substring( 0, container.getOffset() ) );
sb.append( record.toFormattedString( Utils.getLdifFormatParameters() ) );
sb.append( old.substring( container.getOffset() + container.getLength(), old.length() ) );
document.set( sb.toString() );
}
editor.activateGlobalActionHandlers();
}
}