Package org.apache.directory.ldapstudio.schemas.model

Examples of org.apache.directory.ldapstudio.schemas.model.Schema


        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 );
                    }
                }
            }
        }
    }
View Full Code Here


        // We have to check on which node we are to get the schema name
        if ( selection != null )
        {

            Schema schema = null;

            if ( selection instanceof SchemaWrapper )
            {
                schema = ( ( SchemaWrapper ) selection ).getMySchema();
            }
            else if ( selection instanceof AttributeTypeWrapper )
            {
                // We have to get the parent of the parent ( AttributeTypeWrapper => IntermediateNode => SchemaWrapper )
                schema = ( ( SchemaWrapper ) ( ( AttributeTypeWrapper ) selection ).getParent().getParent() )
                    .getMySchema();
            }
            else if ( selection instanceof ObjectClassWrapper )
            {
                // We have to get the parent of the parent ( ObjectClassWrapper => IntermediateNode => SchemaWrapper )
                schema = ( ( SchemaWrapper ) ( ( ObjectClassWrapper ) selection ).getParent().getParent() )
                    .getMySchema();
            }
            else if ( selection instanceof IntermediateNode )
            {
                schema = ( ( SchemaWrapper ) ( ( IntermediateNode ) selection ).getParent() ).getMySchema();
            }

            if ( schema != null )
            {
                try
                {
                    schema.save();
                }
                catch ( Exception e )
                {
                    ErrorDialog
                        .openError(
                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            Messages.getString( "SaveAction.Error" ), Messages.getString( "SaveAction.An_error_occurred_when_saving_schema" ) + schema.getName(), new Status( IStatus.ERROR, Application.PLUGIN_ID, 0, "Status Error Message", null ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    logger.debug( "An error occured when saving schema " + schema.getName() ); //$NON-NLS-1$
                }
            }
        }
    }
View Full Code Here

        literal.setDescription( desc );
        literal.setSuperiors( superiors );
        literal.setMay( may );
        literal.setMust( must );

        schema = new Schema( "test" ); //$NON-NLS-1$
    }
View Full Code Here


    public void setUp()
    {
        elementChanged = false;
        schema = new Schema( "test" ); //$NON-NLS-1$
        at = new AttributeType( new AttributeTypeLiteral( "1.2.3" ), schema ); //$NON-NLS-1$
        oc = new ObjectClass( new ObjectClassLiteral( "4.5.6" ), schema ); //$NON-NLS-1$
        schema.addAttributeType( at );
        schema.addObjectClass( oc );
    }
View Full Code Here

    {
        // TODO Auto-generated method stub
        Schema[] schemas = SchemaPool.getInstance().getSchemas();
        for ( int i = 0; i < schemas.length; i++ )
        {
            Schema schema = schemas[i];
            if ( schema.type == Schema.SchemaType.userSchema )
            {
                if ( schema.hasBeenModified() || schema.hasPendingModification() )
                {
                    return true;
                }
            }
        }
View Full Code Here

    {
        // Getting the SchemaPool
        SchemaPool pool = SchemaPool.getInstance();

        // Getting the right schema
        Schema schema = pool.getSchema( schemaName );

        // Creating the new object class and adding it to the schema
        ObjectClassLiteral objectClassLiteral = new ObjectClassLiteral( this.page.getOidField() );
        objectClassLiteral.setNames( new String[] { this.page.getNameField() } );
        objectClassLiteral.setSuperiors( new String[]{ "top" } ); //$NON-NLS-1$
        ObjectClass objectClass = new ObjectClass( objectClassLiteral, schema );
        schema.addObjectClass( objectClass );

        // Opening the associated editor
        ObjectClassFormEditorInput input = new ObjectClassFormEditorInput( objectClass );
        String editorId = ObjectClassFormEditor.ID;
        try
View Full Code Here

                intermediate.clearChildrens();

                Schema[] schemas = this.pool.getSchemas();
                for ( int i = 0; i < schemas.length; i++ )
                {
                    Schema schema = schemas[i];
                    SchemaWrapper schemaWrapper = new SchemaWrapper( schema, ( IntermediateNode ) parentElement );
                    intermediate.addElement( schemaWrapper );
                }
            }

            Object[] temp = intermediate.getChildren();
            return temp;
        }

        else if ( parentElement instanceof SchemaWrapper )
        {
            //we are looking for the childrens of the contained objectClass
            Schema schema = ( ( ( SchemaWrapper ) parentElement ).getMySchema() );

            IntermediateNode attributeTypes = new IntermediateNode(
                "Attribute Types", ( SchemaWrapper ) parentElement, this, IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ); //$NON-NLS-1$
            IntermediateNode objectClasses = new IntermediateNode(
                "Object Classes", ( SchemaWrapper ) parentElement, this, IntermediateNodeType.OBJECT_CLASS_FOLDER ); //$NON-NLS-1$

            // Let's get all Attribute Types defined in the schema
            AttributeType[] attributeTypeList = schema.getAttributeTypesAsArray();
            for ( int i = 0; i < attributeTypeList.length; i++ )
            {
                AttributeType attributeType = attributeTypeList[i];
                attributeTypes.addElement( new PoolManagerAttributeTypeWrapper( attributeType, attributeTypes ) );
            }

            // Let's get all Object Classes defined in the schema
            ObjectClass[] objectClassList = schema.getObjectClassesAsArray();
            for ( int i = 0; i < objectClassList.length; i++ )
            {
                ObjectClass objectClass = objectClassList[i];
                objectClasses.addElement( new PoolManagerObjectClassWrapper( objectClass, objectClasses ) );
            }
View Full Code Here


    public void setUp()
    {
        schemaChanged = false;
        schema = new Schema( "test" ); //$NON-NLS-1$
    }
View Full Code Here

        literal.setNames( new String[]
            { name } );
        literal.setDescription( desc );
        literal.setCollective( true );
        literal.setEquality( equality );
        schema = new Schema( "test" ); //$NON-NLS-1$
    }
View Full Code Here

    public void testNotification() throws Exception
    {
        //Add a schema to the pool -> notification
        pool.addListener( this );
        Schema schema = new Schema( "toto" ); //$NON-NLS-1$
        pool.addSchema( schema );
        assertTrue( poolChanged );

        poolChanged = false;

        //Add an attribute type to a schema inside the pool -> notification
        schema.addAttributeType( new AttributeType( new AttributeTypeLiteral( "1.2.3" ), schema ) ); //$NON-NLS-1$
        assertTrue( poolChanged );

        poolChanged = false;

        //Remove a schema from the pool -> notification
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.schemas.model.Schema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.