else
{
// Getting the SchemaPool
SchemaPool pool = SchemaPool.getInstance();
// Getting the right schema
Schema schema = pool.getSchema( schemaName );
// Check if the schema isn't a core schema (core schema can't be modified
if ( schema.type == Schema.SchemaType.coreSchema )
{
MessageBox messageBox = new MessageBox(
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OK | SWT.ICON_ERROR );
messageBox
.setMessage( Messages.getString( "DeleteAction.The_schema" ) + schemaName + Messages.getString( "DeleteAction.Is_a_core_schema_It_cant_be_modified" ) ); //$NON-NLS-1$ //$NON-NLS-2$
messageBox.open();
}
else
{
if ( item == DeleteAction.ItemType.attributeType )
{
AttributeType attributeType = ( ( AttributeTypeWrapper ) selection ).getMyAttributeType();
MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION );
messageBox
.setMessage( Messages
.getString( "DeleteAction.Are_you_sure_you_want_to_delete_the_attribute_type" ) + attributeType.getNames()[0] + Messages.getString( "DeleteAction.Interrogation" ) ); //$NON-NLS-1$ //$NON-NLS-2$
if ( messageBox.open() == SWT.OK )
{
schema.removeAttributeType( attributeType );
}
}
else if ( item == DeleteAction.ItemType.objectClass )
{
ObjectClass objectClass = ( ( ObjectClassWrapper ) selection ).getMyObjectClass();
MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION );
messageBox
.setMessage( Messages
.getString( "DeleteAction.Are_you_sure_you_want_to_delete_the_object_class" ) + objectClass.getNames()[0] + Messages.getString( "DeleteAction.Interrogation" ) ); //$NON-NLS-1$ //$NON-NLS-2$
if ( messageBox.open() == SWT.OK )
{
//try to close the associated editors before deleting the objectClass
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = page.getEditorReferences();
for ( IEditorReference reference : editorReferences )
{
try
{
if ( reference.getEditorInput() instanceof ObjectClassFormEditorInput )
{
ObjectClassFormEditorInput input = ( ObjectClassFormEditorInput ) reference
.getEditorInput();
if ( input.getObjectClass().equals( objectClass ) )
{
page.closeEditor( reference.getEditor( false ), false );
}
}
}
catch ( PartInitException e )
{
logger.debug( "error when closing associated editors" ); //$NON-NLS-1$
}
}
//delete the objectClass
schema.removeObjectClass( objectClass );
}
}
}
}
}