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

Examples of org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifModSpec


        }

        // modspecs
        if ( innerContainer instanceof LdifModSpec )
        {
            LdifModSpec modSpec = ( LdifModSpec ) innerContainer;
            String att = modSpec.getModSpecType().getRawAttributeDescription();
            if ( att != null && att.startsWith( prefix ) )
            {
                proposalList.add( new CompletionProposal( att, offset - prefix.length(), prefix.length(), att.length(),
                    null, null, null, null ) );
            }
View Full Code Here


            {

                if ( container instanceof LdifChangeModifyRecord && innerContainer instanceof LdifModSpec
                    && ( part instanceof LdifAttrValLine || part instanceof LdifModSpecTypeLine ) )
                {
                    LdifModSpec modSpec = ( LdifModSpec ) innerContainer;
                    String att = modSpec.getModSpecType().getUnfoldedAttributeDescription();
                    c.text += att + ": ";
                }
            }
        }
View Full Code Here


    protected LdifModSpec getSelectedLdifModSpec()
    {

        LdifModSpec modSpec = null;

        LdifContainer[] containers = getSelectedLdifContainers();
        if ( containers.length == 1 )
        {
            ISourceViewer sourceViewer = ( ISourceViewer ) editor.getAdapter( ISourceViewer.class );
View Full Code Here

                            ldifEditor.selectAndReveal( line.getOffset() + line.getRawAttributeDescription().length()
                                + line.getRawValueType().length(), line.getRawValue().length() );
                        }
                        else if ( element instanceof LdifModSpec )
                        {
                            LdifModSpec modSpec = ( LdifModSpec ) element;
                            ldifEditor.selectAndReveal( modSpec.getOffset(), modSpec.getModSpecType().getLength() );
                        }
                    }
                }
                else if ( editorPart instanceof EntryEditor )
                {
View Full Code Here


    public void update()
    {
        LdifContainer[] containers = getSelectedLdifContainers();
        LdifModSpec modSpec = getSelectedLdifModSpec();
        LdifPart[] parts = getSelectedLdifParts();

        super
            .setEnabled( parts.length == 1
                && ( parts[0] instanceof LdifAttrValLine || modSpec != null )
View Full Code Here

    protected void doRun()
    {

        LdifContainer[] containers = getSelectedLdifContainers();
        LdifModSpec modSpec = getSelectedLdifModSpec();
        LdifPart[] parts = getSelectedLdifParts();
        if ( parts.length == 1
            && ( parts[0] instanceof LdifAttrValLine || parts[0] instanceof LdifModSpecTypeLine )
            && containers.length == 1
            && ( containers[0] instanceof LdifContentRecord || containers[0] instanceof LdifChangeAddRecord || containers[0] instanceof LdifChangeModifyRecord ) )
        {
            try
            {
                LdifValueLineBase line = ( LdifValueLineBase ) parts[0];
                String attributeDescription = null;
                String oldValue = null;
                if ( modSpec != null && line instanceof LdifModSpecTypeLine )
                {
                    LdifModSpecTypeLine oldLine = ( LdifModSpecTypeLine ) line;
                    attributeDescription = oldLine.getUnfoldedAttributeDescription();
                    oldValue = null;
                }
                else
                {
                    LdifAttrValLine oldLine = ( LdifAttrValLine ) line;
                    attributeDescription = oldLine.getUnfoldedAttributeDescription();
                    oldValue = oldLine.getValueAsString();
                }

                Schema schema = editor.getConnection() != null ? editor.getConnection().getSchema()
                    : Schema.DEFAULT_SCHEMA;
                IConnection dummyConnection = new DummyConnection( schema );

                IEntry dummyEntry = null;
                if ( containers[0] instanceof LdifContentRecord )
                {
                    dummyEntry = ModelConverter.ldifContentRecordToEntry( ( LdifContentRecord ) containers[0],
                        dummyConnection );
                }
                else if ( containers[0] instanceof LdifChangeAddRecord )
                {
                    dummyEntry = ModelConverter.ldifChangeAddRecordToEntry( ( LdifChangeAddRecord ) containers[0],
                        dummyConnection );
                }
                else if ( containers[0] instanceof LdifChangeModifyRecord )
                {
                    dummyEntry = new DummyEntry( new DN(), dummyConnection );
                }

                AttributeWizard wizard = new AttributeWizard( "Edit Attribute Description", true, false,
                    attributeDescription, dummyEntry );
                WizardDialog dialog = new WizardDialog( Display.getDefault().getActiveShell(), wizard );
                dialog.setBlockOnOpen( true );
                dialog.create();
                if ( dialog.open() == Dialog.OK )
                {
                    String newAttributeDescription = wizard.getAttributeDescription();

                    if ( newAttributeDescription != null )
                    {
                        IDocument document = editor.getDocumentProvider().getDocument( editor.getEditorInput() );

                        if ( modSpec != null )
                        {
                            LdifModSpecTypeLine oldTypeLine = modSpec.getModSpecType();
                            LdifModSpecTypeLine newTypeLine = null;
                            if ( oldTypeLine.isAdd() )
                            {
                                newTypeLine = LdifModSpecTypeLine.createAdd( newAttributeDescription );
                            }
                            else if ( oldTypeLine.isDelete() )
                            {
                                newTypeLine = LdifModSpecTypeLine.createDelete( newAttributeDescription );
                            }
                            else if ( oldTypeLine.isReplace() )
                            {
                                newTypeLine = LdifModSpecTypeLine.createReplace( newAttributeDescription );
                            }

                            LdifAttrValLine[] oldAttrValLines = modSpec.getAttrVals();
                            LdifAttrValLine[] newAttrValLines = new LdifAttrValLine[oldAttrValLines.length];
                            for ( int i = 0; i < oldAttrValLines.length; i++ )
                            {
                                LdifAttrValLine oldAttrValLine = oldAttrValLines[i];
                                newAttrValLines[i] = LdifAttrValLine.create( newAttributeDescription, oldAttrValLine
                                    .getValueAsString() );

                            }

                            LdifModSpecSepLine newSepLine = LdifModSpecSepLine.create();

                            String text = newTypeLine.toFormattedString();
                            for ( int j = 0; j < newAttrValLines.length; j++ )
                            {
                                text += newAttrValLines[j].toFormattedString();
                            }
                            text += newSepLine.toFormattedString();
                            try
                            {
                                document.replace( modSpec.getOffset(), modSpec.getLength(), text );
                            }
                            catch ( BadLocationException e )
                            {
                                e.printStackTrace();
                            }
View Full Code Here

                        // line.getLength(), DEFAULT_TEXT_ATTRIBUTE);
                    }
                }
                else if ( parts[i] instanceof LdifModSpec )
                {
                    LdifModSpec modSpec = ( LdifModSpec ) parts[i];
                    this.highlight( new LdifContainer[]
                        { modSpec }, presentation, damage );

                }
                else if ( parts[i] instanceof LdifInvalidPart )
View Full Code Here

                List list = ( List ) element;
                return list.toArray();
            }
            else if ( element instanceof LdifModSpec )
            {
                LdifModSpec modSpec = ( LdifModSpec ) element;
                return modSpec.getAttrVals();
            }

            else
            {
                return new Object[0];
View Full Code Here

                return ( ( LdifAttrValLine ) list.get( 0 ) ).getUnfoldedAttributeDescription() + " (" + list.size()
                    + ")";
            }
            else if ( element instanceof LdifModSpec )
            {
                LdifModSpec modSpec = ( LdifModSpec ) element;
                return modSpec.getModSpecType().getUnfoldedAttributeDescription() + " (" + modSpec.getAttrVals().length
                    + ")";
            }

            // AttrValLine
            else if ( element instanceof LdifAttrValLine )
View Full Code Here

            {
                return BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LDIF_ATTRIBUTE );
            }
            else if ( element instanceof LdifModSpec )
            {
                LdifModSpec modSpec = ( LdifModSpec ) element;
                if ( modSpec.isAdd() )
                    return BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LDIF_MOD_ADD );
                else if ( modSpec.isReplace() )
                    return BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LDIF_MOD_REPLACE );
                else if ( modSpec.isDelete() )
                    return BrowserUIPlugin.getDefault().getImage( BrowserUIConstants.IMG_LDIF_MOD_DELETE );
                else
                    return null;
            }
View Full Code Here

TOP

Related Classes of org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifModSpec

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.