public IWizardPage getNextPage()
{
if ( templateButton.getSelection() )
{
final IBrowserConnection browserConnection = entryWidget.getBrowserConnection();
final LdapDN dn = entryWidget.getDn();
IEntry templateEntry = null;
if ( browserConnection == null )
{
getShell().getDisplay().syncExec( new Runnable()
{
public void run()
{
MessageDialog
.openError(
getShell(),
Messages.getString( "NewEntryTypeWizardPage.Error" ), Messages.getString( "NewEntryTypeWizardPage.NoConnection" ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
} );
return null;
}
if ( dn == null )
{
getShell().getDisplay().syncExec( new Runnable()
{
public void run()
{
MessageDialog
.openError(
getShell(),
Messages.getString( "NewEntryTypeWizardPage.Error" ), Messages.getString( "NewEntryTypeWizardPage.NoDN" ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
} );
return null;
}
// check if selected DN exists
ReadEntryRunnable readEntryRunnable = new ReadEntryRunnable( browserConnection, dn );
RunnableContextRunner.execute( readEntryRunnable, getContainer(), false );
templateEntry = readEntryRunnable.getReadEntry();
if ( templateEntry == null )
{
getShell().getDisplay().syncExec( new Runnable()
{
public void run()
{
MessageDialog
.openError(
getShell(),
Messages.getString( "NewEntryTypeWizardPage.Error" ), NLS.bind( Messages.getString( "NewEntryTypeWizardPage.EntryDoesNotExist" ), dn.toString() ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
} );
return null;
}
// init attributes
if ( !templateEntry.isAttributesInitialized() )
{
InitializeAttributesRunnable runnable = new InitializeAttributesRunnable( templateEntry );
RunnableContextRunner.execute( runnable, getContainer(), true );
}
// clone entry and remove non-modifiable attributes
try
{
EventRegistry.suspendEventFiringInCurrentThread();
LdifContentRecord record = ModelConverter.entryToLdifContentRecord( templateEntry );
DummyEntry prototypeEntry = ModelConverter.ldifContentRecordToEntry( record, browserConnection );
IAttribute[] attributes = prototypeEntry.getAttributes();
for ( int i = 0; i < attributes.length; i++ )
{
if ( !SchemaUtils.isModifiable( attributes[i].getAttributeTypeDescription() ) )
{
prototypeEntry.deleteAttribute( attributes[i] );
}
}
wizard.setPrototypeEntry( prototypeEntry );
}
catch ( Exception e )
{
e.printStackTrace();
}
finally
{
EventRegistry.resumeEventFiringInCurrentThread();
}
}
else
{
wizard.setPrototypeEntry( new DummyEntry( new LdapDN(), wizard.getSelectedConnection() ) );
}
return super.getNextPage();
}