Package org.apache.directory.studio.ldapbrowser.core.model.ldif.container

Examples of org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer


        LdifFile ldifModel = this.editor.getLdifModel();
        LdifContainer[] allContainers = ldifModel.getContainers();
        List containerList = new ArrayList();
        for ( int i = 0; i < allContainers.length; i++ )
        {
            LdifContainer container = allContainers[i];
            Region containerRegion = new Region( container.getOffset(), container.getLength() );
            if ( TextUtilities.overlaps( containerRegion, damage ) )
            {
                containerList.add( container );
            }
        }
View Full Code Here


        TextAttribute MODDN_TEXT_ATTRIBUTE = geTextAttribute( LdifEditorConstants.PREFERENCE_LDIFEDITOR_SYNTAX_CHANGETYPEMODDN );

        for ( int z = 0; z < containers.length; z++ )
        {

            LdifContainer container = containers[z];

            LdifPart[] parts = container.getParts();

            for ( int i = 0; i < parts.length; i++ )
            {

                // int offset = damage.getOffset() + parts[i].getOffset();
View Full Code Here

        int errorCount = 0;
        try
        {
            while ( !monitor.isCanceled() && enumeration.hasNext( monitor ) )
            {
                LdifContainer container = enumeration.next( monitor );

                if ( container instanceof LdifRecord )
                {

                    LdifRecord record = ( LdifRecord ) container;
                    try
                    {
                        this.applyModificationAndLog( record, monitor );

                        // update cache and adjust attribute/children initialization flags
                        DN dn = new DN( record.getDnLine().getValueAsString() );
                        IEntry entry = connection.getEntryFromCache( dn );
                        DN parentDn = dn.getParentDn();
                        IEntry parentEntry = parentDn != null ? connection.getEntryFromCache( dn.getParentDn() ) : null;

                        if ( record instanceof LdifChangeDeleteRecord )
                        {
                            if ( entry != null )
                            {
                                entry.setAttributesInitialized( false );
                                connection.uncacheEntry( entry );
                            }
                            if ( parentEntry != null )
                            {
                                parentEntry.setChildrenInitialized( false );
                            }
                        }
                        else if ( record instanceof LdifChangeModDnRecord )
                        {
                            if ( entry != null )
                            {
                                entry.setAttributesInitialized( false );
                                connection.uncacheEntry( entry );
                            }
                            if ( parentEntry != null )
                            {
                                parentEntry.setChildrenInitialized( false );
                            }
                            LdifChangeModDnRecord modDnRecord = ( LdifChangeModDnRecord ) record;
                            if ( modDnRecord.getNewsuperiorLine() != null )
                            {
                                DN newSuperiorDn = new DN( modDnRecord.getNewsuperiorLine().getValueAsString() );
                                IEntry newSuperiorEntry = connection.getEntryFromCache( newSuperiorDn );
                                if ( newSuperiorEntry != null )
                                {
                                    newSuperiorEntry.setChildrenInitialized( false );
                                }
                            }
                        }
                        else if ( record instanceof LdifChangeAddRecord || record instanceof LdifContentRecord )
                        {
                            if ( parentEntry != null )
                            {
                                parentEntry.setChildrenInitialized( false );
                            }
                        }
                        else
                        {
                            if ( entry != null )
                            {
                                entry.setAttributesInitialized( false );
                            }
                        }

                        logModification( logWriter, record, monitor );

                        importedCount++;
                    }
                    catch ( Exception e )
                    {

                        logModificationError( logWriter, record, e, monitor );

                        errorCount++;

                        if ( !continueOnError )
                        {
                            monitor.reportError( e );
                            return;
                        }
                    }

                    monitor.reportProgress( BrowserCoreMessages.bind(
                        BrowserCoreMessages.ldif__imported_n_entries_m_errors, new String[]
                            { "" + importedCount, "" + errorCount } ) ); //$NON-NLS-1$ //$NON-NLS-2$
                }
                else
                {
                    logWriter.write( container.toRawString() );
                }
            }

            if ( errorCount > 0 )
            {
View Full Code Here

                    LdifEnumeration enumeration = connection.connectionProvider.search( searchParameter, monitor );

                    // iterate through the search result
                    while ( !monitor.isCanceled() && enumeration.hasNext( monitor ) )
                    {
                        LdifContainer container = enumeration.next( monitor );
                        if ( container instanceof LdifContentRecord )
                        {

                            LdifContentRecord record = ( LdifContentRecord ) container;
                            DN dn = new DN( record.getDnLine().getValueAsString() );
View Full Code Here

        try
        {
            LdifEnumeration enumeration = this.parse( new StringReader( ldif ) );
            while ( enumeration.hasNext( null ) )
            {
                LdifContainer container = enumeration.next( null );
                model.addContainer( container );
            }
        }
        catch ( ConnectionException e )
        {
View Full Code Here

     */
    public void scrollToNewest()
    {
        try
        {
            LdifContainer record = view.getMainWidget().getLdifModel().getLastContainer();
            int offset = record.getOffset();
            int line = view.getMainWidget().getSourceViewer().getDocument().getLineOfOffset( offset );
            if ( line > 3 )
                line -= 3;
            view.getMainWidget().getSourceViewer().setTopIndex( line );
        }
View Full Code Here

            StringBuffer sb = new StringBuffer();
            sb.append( old.substring( 0, containers[0].getOffset() ) );

            for ( int i = 0; i < containers.length; i++ )
            {
                LdifContainer container = containers[i];
                sb.append( container.toFormattedString() );
            }

            sb.append( old.substring( containers[containers.length - 1].getOffset()
                + containers[containers.length - 1].getLength(), old.length() ) );
View Full Code Here

    public void update()
    {
        LdifContainer[] ldifContainers = super.getSelectedLdifContainers();
        for ( int i = 0; i < ldifContainers.length; i++ )
        {
            LdifContainer container = ldifContainers[i];
            if ( !( container instanceof LdifRecord ) )
            {
                super.setEnabled( false );
                return;
            }
View Full Code Here

        LdifContainer[] containers = getSelectedLdifContainers();
        if ( containers.length == 1
            && ( containers[0] instanceof LdifContentRecord || containers[0] instanceof LdifChangeAddRecord ) )
        {

            LdifContainer container = containers[0];

            LdifEntryEditorDialog dialog = null;
            if ( container instanceof LdifContentRecord )
            {
                dialog = new LdifEntryEditorDialog( editor.getEditorSite().getShell(), editor.getConnection(),
                    ( LdifContentRecord ) container );
            }
            else
            {
                dialog = new LdifEntryEditorDialog( editor.getEditorSite().getShell(), editor.getConnection(),
                    ( LdifChangeAddRecord ) container );
            }

            editor.deactivateGlobalActionHandlers();
            if ( dialog.open() == LdifEntryEditorDialog.OK )
            {
                LdifRecord record = dialog.getLdifRecord();

                IDocument document = editor.getDocumentProvider().getDocument( editor.getEditorInput() );
                String old = document.get();
                StringBuffer sb = new StringBuffer();
                sb.append( old.substring( 0, container.getOffset() ) );
                sb.append( record.toFormattedString() );
                sb.append( old.substring( container.getOffset() + container.getLength(), old.length() ) );
                document.set( sb.toString() );
            }
            editor.activateGlobalActionHandlers();
        }
    }
View Full Code Here

            .getInt( LdifEditorConstants.PREFERENCE_LDIFEDITOR_CONTENTASSIST_AUTOACTIVATIONDELAY ) );

        List proposalList = new ArrayList();

        LdifFile model = editor.getLdifModel();
        LdifContainer container = LdifFile.getContainer( model, offset );
        LdifContainer innerContainer = container != null ? LdifFile.getInnerContainer( container, offset ) : null;
        LdifPart part = container != null ? LdifFile.getContainerContent( container, offset ) : null;
        int documentLine = -1;
        int documentLineOffset = -1;
        String prefix = "";
        try
View Full Code Here

TOP

Related Classes of org.apache.directory.studio.ldapbrowser.core.model.ldif.container.LdifContainer

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.