Package org.eclipse.jface.text.contentassist

Examples of org.eclipse.jface.text.contentassist.CompletionProposal


            LdifRecord record = ( LdifRecord ) container;
            LdifPart[] parts = record.getParts();
            if ( parts.length > 1 && ( !( parts[1] instanceof LdifChangeTypeLine ) || !parts[1].isValid() ) )
            {
                if ( CT_ADD.startsWith( prefix ) )
                    proposalList.add( new CompletionProposal( CT_ADD, offset - prefix.length(), prefix.length(), CT_ADD
                        .length(), LdifEditorActivator.getDefault().getImage( LdifEditorConstants.IMG_LDIF_ADD ),
                        CT_ADD.substring( 0, CT_ADD.length() - BrowserCoreConstants.LINE_SEPARATOR.length() ), null,
                        null ) );
                if ( CT_MODIFY.startsWith( prefix ) )
                    proposalList.add( new CompletionProposal( CT_MODIFY, offset - prefix.length(), prefix.length(),
                        CT_MODIFY.length(), LdifEditorActivator.getDefault().getImage(
                            LdifEditorConstants.IMG_LDIF_MODIFY ), CT_MODIFY.substring( 0, CT_MODIFY.length()
                            - BrowserCoreConstants.LINE_SEPARATOR.length() ), null, null ) );
                if ( CT_DELETE.startsWith( prefix ) )
                    proposalList.add( new CompletionProposal( CT_DELETE, offset - prefix.length(), prefix.length(),
                        CT_DELETE.length(), LdifEditorActivator.getDefault().getImage(
                            LdifEditorConstants.IMG_LDIF_DELETE ), CT_DELETE.substring( 0, CT_DELETE.length()
                            - BrowserCoreConstants.LINE_SEPARATOR.length() ), null, null ) );
                if ( CT_MODDN.startsWith( prefix ) )
                    proposalList.add( new CompletionProposal( CT_MODDN, offset - prefix.length(), prefix.length(),
                        CT_MODDN.length(), LdifEditorActivator.getDefault().getImage(
                            LdifEditorConstants.IMG_LDIF_RENAME ), CT_MODDN.substring( 0, CT_MODDN.length()
                            - BrowserCoreConstants.LINE_SEPARATOR.length() ), null, null ) );
            }

        }

        // changetype: modify
        if ( container instanceof LdifChangeModDnRecord )
        {
            LdifChangeModDnRecord record = ( LdifChangeModDnRecord ) container;
            if ( ( record.getNewrdnLine() == null || !record.getNewrdnLine().isValid() )
                && MD_NEWRDN.startsWith( prefix ) )
            {
                proposalList.add( new CompletionProposal( MD_NEWRDN, offset - prefix.length(), prefix.length(),
                    MD_NEWRDN.length(), null, null, null, null ) );
            }
            if ( ( record.getDeloldrdnLine() == null || !record.getDeloldrdnLine().isValid() )
                && MD_DELETEOLDRDN_TRUE.startsWith( prefix ) )
            {
                proposalList.add( new CompletionProposal( MD_DELETEOLDRDN_TRUE, offset - prefix.length(), prefix
                    .length(), MD_DELETEOLDRDN_TRUE.length(), null, null, null, null ) );
            }
            if ( ( record.getNewsuperiorLine() == null || !record.getNewsuperiorLine().isValid() )
                && MD_NEWSUPERIOR.startsWith( prefix ) )
            {
                proposalList.add( new CompletionProposal( MD_NEWSUPERIOR, offset - prefix.length(), prefix.length(),
                    MD_NEWSUPERIOR.length(), null, null, null, null ) );
            }
        }

        // 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 ) );
            }
        }

        // attribute descriptions
        if ( container instanceof LdifContentRecord || container instanceof LdifChangeAddRecord )
        {

            if ( part instanceof LdifInvalidPart
                || part instanceof LdifAttrValLine
                || ( part instanceof LdifSepLine && ( container instanceof LdifContentRecord || container instanceof LdifChangeAddRecord ) ) )
            {

                String rawAttributeDescription = prefix;
                String rawValueType = ""; //$NON-NLS-1$

                if ( part instanceof LdifAttrValLine )
                {
                    LdifAttrValLine line = ( LdifAttrValLine ) part;
                    rawAttributeDescription = line.getRawAttributeDescription();
                    rawValueType = line.getRawValueType();
                }

                if ( offset <= part.getOffset() + rawAttributeDescription.length() )
                {
                    Schema schema = editor.getConnection() != null ? editor.getConnection().getSchema()
                        : Schema.DEFAULT_SCHEMA;
                    String[] attributeNames = SchemaUtils.getNamesAsArray( schema.getAttributeTypeDescriptions() );
                    Arrays.sort( attributeNames );
                    for ( String attributeName : attributeNames )
                    {
                        if ( rawAttributeDescription.length() == 0
                            || attributeName.toLowerCase().startsWith( rawAttributeDescription.toLowerCase() ) )
                        {

                            String proposal = attributeName;

                            if ( rawValueType.length() == 0 )
                            {
                                if ( SchemaUtils.isBinary( schema.getAttributeTypeDescription( proposal ), schema ) )
                                {
                                    proposal += ":: "; //$NON-NLS-1$
                                }
                                else
                                {
                                    proposal += ": "; //$NON-NLS-1$
                                }
                            }

                            proposalList
                                .add( new CompletionProposal( proposal, offset - rawAttributeDescription.length(),
                                    rawAttributeDescription.length(), proposal.length() ) );
                        }
                    }
                }
            }
        }

        // comment
        boolean commentOnly = false;
        if ( documentLineOffset == offset )
        {
            commentOnly = proposalList.isEmpty();
            proposalList.add( new CompletionProposal( "# ", offset, 0, 2, LdifEditorActivator.getDefault().getImage( //$NON-NLS-1$
                LdifEditorConstants.IMG_LDIF_COMMENT ), "# - Comment", null, null ) ); //$NON-NLS-1$
        }

        // adjust auto-insert
        this.contentAssistant.enableAutoInsert( !commentOnly );
View Full Code Here


            Point selectedRange) {
        String qualifier = ivyfile.getQualifier();
        int qlen = qualifier.length();
        if (qualifier.indexOf('/') > -1) {
            String text = "/>";
            CompletionProposal proposal = new CompletionProposal(text, ivyfile.getOffset() - qlen,
                    qlen + selectedRange.y, text.length());
            propList.add(proposal);
        } else {
            String parent = ivyfile.getParentTagName();
            IvyTag tag = _model.getIvyTag(tagName, parent);
            if (tag == null) {
                errorMessage = "tag :" + tagName + " not found in model:";
                return;
            }
            errorMessage = null;
            List atts = tag.getAttributes();
            Map existingAtts = ivyfile.getAllAttsValues();
            // Loop through all proposals
            for (Iterator iter = atts.iterator(); iter.hasNext();) {
                IvyTagAttribute att = (IvyTagAttribute) iter.next();
                if (att.getName().startsWith(qualifier) && !existingAtts.containsKey(att.getName())) {
                    // Yes -- compute whole proposal text
                    String text = att.getName() + "=\"\"";
                    // Construct proposal
                    CompletionProposal proposal = new CompletionProposal(text, ivyfile.getOffset()
                            - qlen, qlen + selectedRange.y, text.length() - 1, null, att.getName(),
                            null, att.getDoc());
                    // and add to result list
                    propList.add(proposal);
                }
View Full Code Here

                String qualifier = ivyfile.getAttributeValueQualifier();
                int qlen = qualifier == null ? 0 : qualifier.length();
                Arrays.sort(values);
                for (int i = 0; i < values.length; i++) {
                    String val = values[i];
                    CompletionProposal proposal = new CompletionProposal(val, ivyfile.getOffset()
                            - qlen, qlen + selection.y, val.length());
                    propList.add(proposal);
                }
            }
        }
View Full Code Here

                && ivyfile.getOffset() >= 2 + qualifier.length()
                && ivyfile.getString(ivyfile.getOffset() - 2 - qualifier.length(),
                    ivyfile.getOffset()).startsWith("</")) {
            // closing tag (already started)
            String text = "</" + parent + ">";
            CompletionProposal proposal = new CompletionProposal(text, ivyfile.getOffset() - qlen
                    - 2, qlen + 2 + selectedRange.y, text.length());
            propList.add(proposal);
        } else {
            if (parent != null && qualifier.length() == 0) {
                String text = "</" + parent + ">";
                int closingIndex = ivyfile.getStringIndexForward(text);
                int openingIndex = ivyfile.getStringIndexForward("<" + parent);
                if (closingIndex == -1 || (openingIndex != -1 && closingIndex > openingIndex)) {
                    // suggest closing tag if tag not yet closed
                    CompletionProposal proposal = new CompletionProposal(text, ivyfile.getOffset(),
                            selectedRange.y, text.length());
                    propList.add(proposal);
                }
            }

            List childs = null;

            if (parent != null) {
                String parentParent = ivyfile.getParentTagName(ivyfile.getStringIndexBackward("<"
                        + parent));
                IvyTag root = _model.getIvyTag(parent, parentParent);
                if (root == null) {
                    errorMessage = "parent tag :" + parent + " not found in model:";
                    return;
                } else {
                    childs = root.getChilds();
                }
            } else {
                childs = Collections.singletonList(_model.getRootIvyTag());
            }
            errorMessage = null;
            for (Iterator iter = childs.iterator(); iter.hasNext();) {
                IvyTag child = (IvyTag) iter.next();

                // Check if proposal matches qualifier
                if (child.getStartTag().startsWith(qualifier)) {
                    Proposal[] props = child.getProposals();
                    for (int i = 0; i < props.length; i++) {
                        // Construct proposal and add to result list
                        propList.add(new CompletionProposal(props[i].getProposal(), ivyfile
                                .getOffset()
                                - qlen, qlen + selectedRange.y, props[i].getCursor(), null, null,
                                null, props[i].getDoc()));
                    }
                }
View Full Code Here

                    else
                    {
                        displayString += " (" + description.getNumericOid() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                    }
                    String info = SchemaUtils.getLdifLine( description );
                    ICompletionProposal proposal = new CompletionProposal( replacementString, offset, attributeType
                        .length(), replacementString.length(), getAttributeTypeImage(), displayString, null, info );
                    proposalList.add( proposal );
                }
            }
        }
View Full Code Here

            for ( String possibleFilterType : copy.keySet() )
            {
                String replacementString = possibleFilterType;
                String displayString = copy.get( possibleFilterType );

                ICompletionProposal proposal = new CompletionProposal( replacementString, offset, filterType.length(),
                    possibleFilterType.length(), getFilterTypeImage(), displayString, null, null );
                proposalList.add( proposal );
            }
        }
    }
View Full Code Here

                    else
                    {
                        displayString += " (" + description.getNumericOid() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                    }

                    ICompletionProposal proposal = new CompletionProposal( replacementString, offset, objectClass
                        .length(), replacementString.length(), getObjectClassImage(), displayString, null, SchemaUtils
                        .getLdifLine( schema.getObjectClassDescription( possibleObjectClass ) ) );
                    proposalList.add( proposal );
                }
            }
View Full Code Here

                    else
                    {
                        displayString += " (" + description.getNumericOid() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
                    }
                    String info = SchemaUtils.getLdifLine( description );
                    ICompletionProposal proposal = new CompletionProposal( replacementString, offset, matchingRule
                        .length(), replacementString.length(), getMatchingRuleImage(), displayString, null, info );
                    proposalList.add( proposal );
                }
            }
        }
View Full Code Here

    {
        if ( "dn".toUpperCase().startsWith( dnAttr.toUpperCase() ) ) //$NON-NLS-1$
        {
            String replacementString = "dn:"; //$NON-NLS-1$
            String displayString = "dn: ()"; //$NON-NLS-1$
            ICompletionProposal proposal = new CompletionProposal( replacementString, offset, dnAttr.length(),
                replacementString.length(), null, displayString, null, null );
            proposalList.add( proposal );
        }
    }
View Full Code Here

   * Method declared on IContentAssistProcessor
   */
  public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
    ICompletionProposal[] result= new ICompletionProposal[fgProposals.length];
    for (int i= 0; i < fgProposals.length; i++)
      result[i]= new CompletionProposal(fgProposals[i], documentOffset, 0, fgProposals[i].length());
    return result;
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.contentassist.CompletionProposal

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.