Package org.apache.directory.ldapstudio.browser.core.model

Examples of org.apache.directory.ldapstudio.browser.core.model.IAttribute


    public boolean select( Viewer viewer, Object parentElement, Object element )
    {

        if ( element instanceof IAttribute )
        {
            IAttribute attribute = ( IAttribute ) element;

            // check if one of the values goes through the quick filter
            boolean oneGoesThrough = false;
            IValue[] values = attribute.getValues();
            for ( int i = 0; i < values.length; i++ )
            {
                if ( this.goesThroughQuickFilter( values[i] ) )
                {
                    oneGoesThrough = true;
View Full Code Here



    public Color getForeground( Object element )
    {

        IAttribute attribute = null;
        IValue value = null;
        if ( element instanceof IAttribute )
        {
            attribute = ( IAttribute ) element;
        }
        else if ( element instanceof IValue )
        {
            value = ( IValue ) element;
            attribute = value.getAttribute();
        }

        // inconsistent attributes and values
        if ( value != null )
        {
            if ( value.isEmpty() )
            {
                RGB rgb = PreferenceConverter.getColor( BrowserUIPlugin.getDefault().getPreferenceStore(),
                    BrowserUIConstants.PREFERENCE_ERROR_COLOR );
                return BrowserUIPlugin.getDefault().getColor( rgb );
            }
        }
        if ( attribute != null && value == null )
        {
            if ( !attribute.isConsistent() )
            {
                RGB rgb = PreferenceConverter.getColor( BrowserUIPlugin.getDefault().getPreferenceStore(),
                    BrowserUIConstants.PREFERENCE_ERROR_COLOR );
                return BrowserUIPlugin.getDefault().getColor( rgb );
            }
        }

        // attribute type
        if ( attribute != null )
        {
            if ( attribute.isObjectClassAttribute() )
            {
                RGB rgb = PreferenceConverter.getColor( BrowserUIPlugin.getDefault().getPreferenceStore(),
                    BrowserUIConstants.PREFERENCE_OBJECTCLASS_COLOR );
                return BrowserUIPlugin.getDefault().getColor( rgb );
            }
            else if ( attribute.isMustAttribute() )
            {
                RGB rgb = PreferenceConverter.getColor( BrowserUIPlugin.getDefault().getPreferenceStore(),
                    BrowserUIConstants.PREFERENCE_MUSTATTRIBUTE_COLOR );
                return BrowserUIPlugin.getDefault().getColor( rgb );
            }
            else if ( attribute.isOperationalAttribute() )
            {
                RGB rgb = PreferenceConverter.getColor( BrowserUIPlugin.getDefault().getPreferenceStore(),
                    BrowserUIConstants.PREFERENCE_OPERATIONALATTRIBUTE_COLOR );
                return BrowserUIPlugin.getDefault().getColor( rgb );
            }
View Full Code Here

        // }
        // else if (o1 != null && o2 == null) {
        // return this.greaterThan();
        // }
        // else {
        IAttribute attribute1 = null;
        IValue value1 = null;
        if ( o1 instanceof IAttribute )
        {
            attribute1 = ( IAttribute ) o1;
        }
        else if ( o1 instanceof IValue )
        {
            value1 = ( IValue ) o1;
            attribute1 = value1.getAttribute();
        }

        IAttribute attribute2 = null;
        IValue value2 = null;
        if ( o2 instanceof IAttribute )
        {
            attribute2 = ( IAttribute ) o2;
        }
View Full Code Here

    public Object[] getChildren( Object parentElement )
    {
        if ( parentElement instanceof IAttribute )
        {
            IAttribute attribute = ( IAttribute ) parentElement;
            IValue[] values = attribute.getValues();
            return values;
        }
        return null;
    }
View Full Code Here

            if ( parts[i] instanceof LdifAttrValLine )
            {
                LdifAttrValLine line = ( LdifAttrValLine ) parts[i];
                String attributeName = line.getUnfoldedAttributeDescription();
                Object value = line.getValueAsObject();
                IAttribute attribute = entry.getAttribute( attributeName );
                if ( attribute == null )
                {
                    attribute = new Attribute( entry, attributeName );
                    entry.addAttribute( attribute );
                }
                attribute.addValue( new Value( attribute, value ) );
            }
            else if ( !( parts[i] instanceof LdifDnLine ) && !( parts[i] instanceof LdifSepLine ) )
            {
                String name = parts[i].toRawString();
                name = name.replaceAll( "\n", "" );
                name = name.replaceAll( "\r", "" );
                IAttribute attribute = new Attribute( entry, name );
                attribute.addValue( new Value( attribute, parts[i] ) );
                entry.addAttribute( attribute );
                // IAttribute attribute = entry.getAttribute("");
                // if(attribute == null) {
                // attribute = new Attribute(entry, "");
                // entry.addAttribute(attribute, null);
View Full Code Here

    public static IValue ldifAttrValLineToValue( LdifAttrValLine line, IEntry entry )
    {
        try
        {
            IAttribute attribute = new Attribute( entry, line.getUnfoldedAttributeDescription() );
            IValue value = new Value( attribute, line.getValueAsObject() );
            return value;
        }
        catch ( Exception e )
        {
View Full Code Here

            Set suppportedConrolSet = new HashSet();
            if ( connection.getRootDSE() != null
                && connection.getRootDSE().getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL ) != null )
            {
                IAttribute scAttribute = connection.getRootDSE().getAttribute(
                    IRootDSE.ROOTDSE_ATTRIBUTE_SUPPORTEDCONTROL );
                String[] supportedControls = scAttribute.getStringValues();
                for ( int i = 0; i < supportedControls.length; i++ )
                {
                    suppportedConrolSet.add( supportedControls[i].toLowerCase() );
                }
            }
View Full Code Here

                    AttributeHierarchy ah = entry.getAttributeWithSubtypes( ras[r] );
                    if ( ah != null )
                    {
                        for ( Iterator it = ah.iterator(); it.hasNext(); )
                        {
                            IAttribute attribute = ( IAttribute ) it.next();
                            try
                            {
                                entry.deleteAttribute( attribute );
                            }
                            catch ( ModelModificationException e )
                            {
                            }
                        }
                    }
                }
            }
            else
            {
                // clear all
                IAttribute[] oldAttributes = entry.getAttributes();
                for ( int i = 0; oldAttributes != null && i < oldAttributes.length; i++ )
                {
                    try
                    {
                        entry.deleteAttribute( oldAttributes[i] );
                    }
                    catch ( ModelModificationException e )
                    {
                    }
                }
            }


            // additional clear old attributes if the record contains the
            // attribute
            for ( int i = 0; i < lines.length; i++ )
            {
                String attributeDesc = lines[i].getUnfoldedAttributeDescription();
                IAttribute oldAttribute = entry.getAttribute( attributeDesc );
                if ( oldAttribute != null )
                {
                    try
                    {
                        entry.deleteAttribute( oldAttribute );
                    }
                    catch ( ModelModificationException mme )
                    {
                    }
                }
            }

            // set new attributes and values
            for ( int i = 0; i < lines.length; i++ )
            {

                IAttribute attribute = null;
                String attributeName = lines[i].getUnfoldedAttributeDescription();
                // attributeName = attributeName.replaceAll(";binary", "");
                if ( entry.getAttribute( attributeName ) == null )
                {
                    attribute = new Attribute( entry, attributeName );
                    entry.addAttribute( attribute );
                }
                else
                {
                    attribute = entry.getAttribute( attributeName );
                }

                attribute.addValue( new Value( attribute, lines[i].getValueAsObject() ) );
            }
        }
    }
View Full Code Here

                List baseDnEntryList = new ArrayList();
                String[] baseDnAttributeNames = new String[]
                    { IRootDSE.ROOTDSE_ATTRIBUTE_NAMINGCONTEXTS };
                for ( int x = 0; x < baseDnAttributeNames.length; x++ )
                {
                    IAttribute attribute = this.rootDSE.getAttribute( baseDnAttributeNames[x] );
                    if ( attribute != null )
                    {
                        String[] values = attribute.getStringValues();
                        for ( int i = 0; i < values.length; i++ )
                        {
                            if ( !"".equals( values[i] ) ) { //$NON-NLS-1$
                                baseDnEntryList.add( values[i] );
                            }
View Full Code Here

    private DirectoryMetadataEntry[] getDirectoryMetadataEntries( String metadataAttributeName )
        throws ModelModificationException
    {
        List metadataEntryList = new ArrayList();
        IAttribute attribute = this.rootDSE.getAttribute( metadataAttributeName );
        if ( attribute != null )
        {
            String[] values = attribute.getStringValues();
            for ( int i = 0; i < values.length; i++ )
            {
                try
                {
                    metadataEntryList.add( new DN( values[i] ) );
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.browser.core.model.IAttribute

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.