Package org.apache.directory.ldapstudio.schemas.view.views.wrappers

Examples of org.apache.directory.ldapstudio.schemas.view.views.wrappers.ITreeNode


     *      the Schema Element
     */
    private void linkViewWithEditor( SchemaElement schemaElement )
    {
        StructuredSelection structuredSelection = null;
        ITreeNode wrapper = null;

        if ( schemaElement instanceof AttributeType )
        {
            wrapper = new AttributeTypeWrapper( ( AttributeType ) schemaElement, null );
            structuredSelection = new StructuredSelection( wrapper );

            view.getViewer().setSelection( structuredSelection, true );
        }
        else if ( schemaElement instanceof ObjectClass )
        {
            wrapper = new ObjectClassWrapper( ( ObjectClass ) schemaElement, null );
            structuredSelection = new StructuredSelection( wrapper );
        }
        else
        {
            return;
        }

        Object foundItem = view.getViewer().testFindItem( wrapper );
        if ( foundItem != null ) // The node we are looking for is already loaded in the TreeViewer
        {
            view.getViewer().setSelection( structuredSelection, true );
        }
        else
        // The node we are looking for is not yet loaded in the TreeViewer, we have to find and load it.
        {
            ITreeNode foundElement = view.findElementInTree( wrapper );

            if ( foundElement != null )
            {
                expandFromTopToBottom( foundElement );
                view.getViewer().setSelection( structuredSelection );
View Full Code Here


        // 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 )
            {
                wrapper.getParent().removeChild( wrapper );
            }
        }

        viewer.refresh();
    }
View Full Code Here

     * @param e
     *      the event
     */
    private void aTOrOCModified( SchemaPool p, LDAPModelEvent e )
    {
        ITreeNode wrapper = getWrapper( ( SchemaElement ) e.getNewValue() );
        if ( wrapper != null )
        {
            viewer.update( wrapper, null );
        }
    }
View Full Code Here

     * @param e
     *      the event
     */
    private void aTOrOCRemoved( SchemaPool p, LDAPModelEvent e )
    {
        ITreeNode wrapper = getWrapper( ( SchemaElement ) e.getOldValue() );
        if ( wrapper != null )
        {
            wrapper.getParent().removeChild( wrapper );
            viewer.refresh();
        }
    }
View Full Code Here

        if ( element == null )
        {
            return null;
        }

        ITreeNode input = ( ITreeNode ) getViewer().getInput();

        return findElementInTree( element, input );
    }
View Full Code Here

        else
        {
            Object[] children = contentProvider.getChildren( node );
            for ( Object child : children )
            {
                ITreeNode foundElement = findElementInTree( element, ( ITreeNode ) child );
                if ( foundElement != null )
                {
                    return foundElement;
                }
            }
View Full Code Here

    {
        Object[] children = contentProvider.getChildren( ( ITreeNode ) getViewer().getInput() );

        for ( Object child : children )
        {
            ITreeNode item = ( ITreeNode ) child;
            if ( item.equals( element ) )
            {
                return item;
            }
        }
View Full Code Here

     *      the object
     */
    private void linkViewWithEditor( Object o )
    {
        StructuredSelection structuredSelection = null;
        ITreeNode wrapper = null;

        if ( o instanceof AttributeType )
        {
            wrapper = new AttributeTypeWrapper( ( AttributeType ) o, null );
            structuredSelection = new StructuredSelection( wrapper );
        }
        else if ( o instanceof ObjectClass )
        {
            wrapper = new ObjectClassWrapper( ( ObjectClass ) o, null );
            structuredSelection = new StructuredSelection( wrapper );
        }
        else if ( o instanceof Schema )
        {
            wrapper = new SchemaWrapper( ( Schema ) o, null );
            structuredSelection = new StructuredSelection( wrapper );
        }
        else
        {
            // If the editor isn't an attribute type editor or object class editor, we return
            return;
        }

        Object foundItem = schemasView.getViewer().testFindItem( wrapper );
        if ( foundItem != null ) // The node we are looking for is already loaded in the TreeViewer
        {
            schemasView.getViewer().setSelection( structuredSelection, true );
        }
        else
        // The node we are looking for is not yet loaded in the TreeViewer, we have to find and load it.
        {
            ITreeNode foundElement = schemasView.findElementInTree( wrapper );

            if ( foundElement != null )
            {
                expandFromTopToBottom( foundElement );
                schemasView.getViewer().setSelection( structuredSelection );
View Full Code Here

     * @param e
     *      the event
     */
    private void schemaAdded( SchemaPool p, LDAPModelEvent e )
    {
        ITreeNode rootNode = ( ITreeNode ) viewer.getInput();
        SchemaWrapper schemaWrapper = new SchemaWrapper( ( Schema ) e.getNewValue(), rootNode );
        rootNode.addChild( schemaWrapper );

        Collections.sort( rootNode.getChildren(), new SchemaSorter() );

        viewer.refresh( rootNode );
        viewer.setSelection( new StructuredSelection( schemaWrapper ) );
    }
View Full Code Here

     * @param e
     *      the event
     */
    private void schemaRemoved( SchemaPool p, LDAPModelEvent e )
    {
        ITreeNode rootNode = ( ITreeNode ) viewer.getInput();

        List<ITreeNode> schemaWrapperList = rootNode.getChildren();
        for ( Iterator iter = schemaWrapperList.iterator(); iter.hasNext(); )
        {
            SchemaWrapper schemaWrapper = ( SchemaWrapper ) iter.next();
            if ( schemaWrapper.getMySchema().equals( ( Schema ) e.getOldValue() ) )
            {
                rootNode.removeChild( schemaWrapper );
                viewer.refresh( rootNode );
                break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.schemas.view.views.wrappers.ITreeNode

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.