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

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


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

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

        // Creating the new attribute type and adding it to the schema
        AttributeTypeLiteral attributeTypeLiteral = new AttributeTypeLiteral( this.page.getOidField() );
        attributeTypeLiteral.setNames( new String[]
            { this.page.getNameField() } );
        AttributeType attributeType = new AttributeType( attributeTypeLiteral, schema );
        schema.addAttributeType( attributeType );

        // Opening the associated editor
        AttributeTypeEditorInput input = new AttributeTypeEditorInput( attributeType );
        String editorId = AttributeTypeEditor.ID;
        try
View Full Code Here


     *      the event
     */
    private void schemaAdded( SchemaPool p, LDAPModelEvent e )
    {
        SchemaElementsViewRoot root = ( SchemaElementsViewRoot ) viewer.getInput();
        Schema schema = ( Schema ) e.getNewValue();

        // ATTRIBUTE TYPES
        AttributeType[] attributeTypes = schema.getAttributeTypesAsArray();
        for ( AttributeType attributeType : attributeTypes )
        {
            root.addChild( new AttributeTypeWrapper( attributeType, root ) );
        }

        // OBJECT CLASSES
        ObjectClass[] objectClasses = schema.getObjectClassesAsArray();
        for ( ObjectClass objectClass : objectClasses )
        {
            root.addChild( new ObjectClassWrapper( objectClass, root ) );
        }

View Full Code Here

     * @param e
     *      the event
     */
    private void schemaRemoved( SchemaPool p, LDAPModelEvent e )
    {
        Schema schema = ( Schema ) e.getOldValue();

        // ATTRIBUTE TYPES
        AttributeType[] attributeTypes = schema.getAttributeTypesAsArray();
        for ( AttributeType attributeType : attributeTypes )
        {
            ITreeNode wrapper = getWrapper( attributeType );
            if ( wrapper != null )
            {
                wrapper.getParent().removeChild( wrapper );
            }
        }

        // OBJECT CLASSES
        ObjectClass[] objectClasses = schema.getObjectClassesAsArray();
        for ( ObjectClass objectClass : objectClasses )
        {
            ITreeNode wrapper = getWrapper( objectClass );
            if ( wrapper != null )
            {
View Full Code Here

    {
        SchemasView view = ( SchemasView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .findView( SchemasView.ID ); //$NON-NLS-1$
        Object selection = ( ( TreeSelection ) view.getViewer().getSelection() ).getFirstElement();

        Schema schema = null;

        // We have to check on which node we are to get the schema name
        if ( selection instanceof SchemaWrapper )
        {
            schema = ( ( SchemaWrapper ) selection ).getMySchema();
        }
        else if ( selection instanceof AttributeTypeWrapper )
        {
            schema = ( ( AttributeTypeWrapper ) selection ).getMyAttributeType().getOriginatingSchema();
        }
        else if ( selection instanceof ObjectClassWrapper )
        {
            schema = ( ( ObjectClassWrapper ) selection ).getMyObjectClass().getOriginatingSchema();
        }
        else if ( selection instanceof IntermediateNode )
        {
            schema = ( ( SchemaWrapper ) ( ( IntermediateNode ) selection ).getParent() ).getMySchema();
        }
        else
        {
            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                SWT.OK | SWT.ICON_ERROR );
            messageBox.setMessage( Messages.getString( "CreateANewAttributeTypeAction.A_schema_must_be_selected" ) ); //$NON-NLS-1$
            messageBox.open();
            return;
        }

        // 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( "CreateANewAttributeTypeAction.The_schema" ) + schema.getName() + Messages.getString( "CreateANewAttributeTypeAction.Is_a_core_schema_It_cant_be_modified" ) ); //$NON-NLS-1$ //$NON-NLS-2$
            messageBox.open();
        }
        else
        {
            // Instantiates and initializes the wizard
            CreateANewAttributeTypeWizard wizard = new CreateANewAttributeTypeWizard( schema.getName() );
            wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
            // Instantiates the wizard container with the wizard and opens it
            WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                wizard );
            dialog.create();
View Full Code Here

            if ( intermediate.getChildren().isEmpty() )
            {
                if ( intermediate.getType().equals( IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ) )
                {
                    Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();

                    AttributeType[] ats = schema.getAttributeTypesAsArray();
                    for ( AttributeType at : ats )
                    {
                        intermediate.addChild( new AttributeTypeWrapper( at, intermediate ) );
                    }
                }
                else if ( intermediate.getType().equals( IntermediateNodeType.OBJECT_CLASS_FOLDER ) )
                {
                    Schema schema = ( ( SchemaWrapper ) intermediate.getParent() ).getMySchema();

                    ObjectClass[] ocs = schema.getObjectClassesAsArray();
                    for ( ObjectClass oc : ocs )
                    {
                        intermediate.addChild( new ObjectClassWrapper( oc, intermediate ) );
                    }
                }
            }

            children = intermediate.getChildren();

            // Sort by
            if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_FIRSTNAME )
            {
                Collections.sort( children, firstNameSorter );
            }
            else if ( sortBy == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_BY_OID )
            {
                Collections.sort( children, oidSorter );
            }

            // Sort order
            if ( sortOrder == PluginConstants.PREFS_SCHEMAS_VIEW_SORTING_ORDER_DESCENDING )
            {
                Collections.reverse( children );
            }
        }
        else if ( parentElement instanceof SchemaWrapper )
        {
            SchemaWrapper schemaWrapper = ( SchemaWrapper ) parentElement;

            if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_FOLDERS )
            {
                if ( schemaWrapper.getChildren().isEmpty() )
                {
                    IntermediateNode attributeTypes = new IntermediateNode(
                        "Attribute Types", ( SchemaWrapper ) parentElement, IntermediateNodeType.ATTRIBUTE_TYPE_FOLDER ); //$NON-NLS-1$
                    IntermediateNode objectClasses = new IntermediateNode(
                        "Object Classes", ( SchemaWrapper ) parentElement, IntermediateNodeType.OBJECT_CLASS_FOLDER ); //$NON-NLS-1$
                    schemaWrapper.addChild( attributeTypes );
                    schemaWrapper.addChild( objectClasses );
                }

                children = schemaWrapper.getChildren();
            }
            else if ( group == PluginConstants.PREFS_SCHEMAS_VIEW_GROUPING_MIXED )
            {
                if ( schemaWrapper.getChildren().isEmpty() )
                {
                    Schema schema = schemaWrapper.getMySchema();

                    AttributeType[] ats = schema.getAttributeTypesAsArray();
                    for ( AttributeType at : ats )
                    {
                        schemaWrapper.addChild( new AttributeTypeWrapper( at, schemaWrapper ) );
                    }

                    ObjectClass[] ocs = schema.getObjectClassesAsArray();
                    for ( ObjectClass oc : ocs )
                    {
                        schemaWrapper.addChild( new ObjectClassWrapper( oc, schemaWrapper ) );
                    }
                }
View Full Code Here

        if ( schemaName != null )
        {
            // Getting the SchemaPool
            SchemaPool pool = SchemaPool.getInstance();
            // Getting the right schema
            Schema schema = pool.getSchema( schemaName );

            if ( schema.type == Schema.SchemaType.coreSchema )
            {
                MessageBox messageBox = new MessageBox(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OK | SWT.ICON_ERROR );
                messageBox
                    .setMessage( Messages.getString( "RemoveSchemaAction.The_schema" ) + schemaName + Messages.getString( "RemoveSchemaAction.Is_a_core_schema_It_cant_be_removed_from_the_pool" ) ); //$NON-NLS-1$ //$NON-NLS-2$
                messageBox.open();
                return;
            }
            if ( schema.hasBeenModified() || schema.hasPendingModification() )
            {
                MessageBox messageBox = new MessageBox(
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OK | SWT.CANCEL
                        | SWT.ICON_QUESTION );
                messageBox.setMessage( Messages
View Full Code Here

     */
    public int compare( ITreeNode o1, ITreeNode o2 )
    {
        if ( ( o1 instanceof SchemaWrapper ) && ( o2 instanceof SchemaWrapper ) )
        {
            Schema s1 = ( ( SchemaWrapper ) o1 ).getMySchema();
            Schema s2 = ( ( SchemaWrapper ) o2 ).getMySchema();

            return s1.getName().compareToIgnoreCase( s2.getName() );
        }

        // Default
        return o1.toString().compareToIgnoreCase( o2.toString() );
    }
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
        ObjectClassEditorInput input = new ObjectClassEditorInput( objectClass );
        String editorId = ObjectClassEditor.ID;
        try
View Full Code Here

    {
        SchemasView view = ( SchemasView ) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .findView( SchemasView.ID ); //$NON-NLS-1$
        Object selection = ( ( TreeSelection ) view.getViewer().getSelection() ).getFirstElement();

        Schema schema = null;

        // We have to check on which node we are to get the schema name
        if ( selection instanceof SchemaWrapper )
        {
            schema = ( ( SchemaWrapper ) selection ).getMySchema();
        }
        else if ( selection instanceof AttributeTypeWrapper )
        {
            schema = ( ( AttributeTypeWrapper ) selection ).getMyAttributeType().getOriginatingSchema();
        }
        else if ( selection instanceof ObjectClassWrapper )
        {
            schema = ( ( ObjectClassWrapper ) selection ).getMyObjectClass().getOriginatingSchema();
        }
        else if ( selection instanceof IntermediateNode )
        {
            schema = ( ( SchemaWrapper ) ( ( IntermediateNode ) selection ).getParent() ).getMySchema();
        }
        else
        {
            MessageBox messageBox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                SWT.OK | SWT.ICON_ERROR );
            messageBox.setMessage( Messages.getString( "CreateANewObjectClassAction.A_schema_must_be_selected" ) ); //$NON-NLS-1$
            messageBox.open();
            return;
        }

        // 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( "CreateANewObjectClassAction.The_schema" ) + schema.getName() + Messages.getString( "CreateANewObjectClassAction.Is_a_core_schema_It_cant_be_modified" ) ); //$NON-NLS-1$ //$NON-NLS-2$
            messageBox.open();
        }
        else
        {
            // Instantiates and initializes the wizard
            CreateANewObjectClassWizard wizard = new CreateANewObjectClassWizard( schema.getName() );
            wizard.init( PlatformUI.getWorkbench(), StructuredSelection.EMPTY );
            // Instantiates the wizard container with the wizard and opens it
            WizardDialog dialog = new WizardDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                wizard );
            dialog.create();
View Full Code Here

        // We have to check on which node we are to get the schema name
        if ( selection != null )
        {
            if ( selection instanceof SchemaWrapper )
            {
                Schema schema = ( ( SchemaWrapper ) selection ).getMySchema();

                try
                {
                    schema.saveas();
                }
                catch ( Exception e )
                {
                    ErrorDialog
                        .openError(
                            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                            Messages.getString( "SaveAsAction.Error" ), Messages.getString( "SaveAsAction.An_error_occurred_when_saving_schemas" ) + schema.getName(), new Status( IStatus.ERROR, Activator.PLUGIN_ID, 0, //$NON-NLS-1$ //$NON-NLS-2$
                                "Status Error Message", null ) ); //$NON-NLS-1$
                    logger.debug( "An error occured when saving schema " + schema.getName() ); //$NON-NLS-1$
                }
            }
        }
    }
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.