Package org.eclipse.jface.text.contentassist

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


    fRelevance = relevance;
    fUpdateLengthOnValidate = updateReplacementLengthOnValidate;
  }

  public void apply(IDocument document) {
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo());
    proposal.apply(document);
  }
View Full Code Here


   *
   * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#apply(org.eclipse.jface.text.IDocument,
   *      char, int)
   */
  public void apply(IDocument document, char trigger, int offset) {
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo());
    // we currently don't do anything special for which character
    // selected the proposal, and where the cursor offset is
    // but we might in the future...
    proposal.apply(document);
    // we want to ContextInformationPresenter.updatePresentation() here
  }
View Full Code Here

    return fReplacementString;
  }

  public Point getSelection(IDocument document) {
    // return fProposal.getSelection(document);
    CompletionProposal proposal = new CompletionProposal(getReplacementString(), getReplacementOffset(), getReplacementLength(), getCursorPosition(), getImage(), getDisplayString(), getContextInformation(), getAdditionalProposalInfo());
    return proposal.getSelection(document);
  }
View Full Code Here

    if (annotation instanceof TemporaryAnnotation) {
      TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) annotation;
      int problemID = tempAnnotation.getProblemID();
      switch (problemID) {
        case ProblemIDsXML.EmptyTag :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.MissingEndTag :
          String tagName = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
          String tagClose = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1];
          int tagCloseOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[2]).intValue();
          int startTagEndOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[3]).intValue();
          int firstChildStartOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[4]).intValue();
          int endOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[5]).intValue();
          proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), startTagEndOffset - tempAnnotation.getPosition().getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          break;
        case ProblemIDsXML.AttrsInEndTag :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.MissingAttrValue :
          String defaultAttrValue = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
          int insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue();
          proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.NoAttrValue :
          defaultAttrValue = (String) tempAnnotation.getAdditionalFixInfo();
          proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.SpacesBeforeTagName :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.SpacesBeforePI :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_9, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.NamespaceInPI :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_10, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.UnknownElement :
          proposals.add(new RemoveUnknownElementQuickFixProposal(tempAnnotation.getAdditionalFixInfo(), getImage(), XMLUIMessages.QuickFixProcessorXML_11));
          proposals.add(new RenameInFileQuickAssistProposal());
          break;
        case ProblemIDsXML.UnknownAttr :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          proposals.add(new RenameInFileQuickAssistProposal());
          break;
        case ProblemIDsXML.InvalidAttrValue :
          proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_12, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
        case ProblemIDsXML.MissingRequiredAttr :
          String requiredAttr = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
          insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue();
          proposals.add(new CompletionProposal(requiredAttr, tempAnnotation.getPosition().getOffset() + insertOffset, 0, requiredAttr.length(), getImage(), XMLUIMessages.QuickFixProcessorXML_13, null, "")); //$NON-NLS-1$
          break;
        case ProblemIDsXML.AttrValueNotQuoted :
          String attrValue = (String) tempAnnotation.getAdditionalFixInfo();
          proposals.add(new CompletionProposal("\"" + attrValue + "\"", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), attrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_14, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          break;
        case ProblemIDsXML.MissingClosingBracket :
          proposals.add(new CompletionProposal(">", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, 1, getImage(), XMLUIMessages.QuickFixProcessorXML_15, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
          break;
      }
    }

    return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
View Full Code Here

            // Derive cursor position
            int cursor = text.length();

            IContextInformation contextInfo = new ContextInformation(null, text);
            // Construct proposal
            CompletionProposal proposal = new CompletionProposal(text, documentOffset
                - qlen, qlen, cursor, null, text, contextInfo, text
                + "-Event declared in contract");

            // and add to result list
            propList.add(proposal);
          }
        }

        for (IVariable var : model.getContract().getMonitoredVariables())
        {

          String text = var.getName();
          if (qualifier.proposal.toString().trim().length() == 0
              || text.startsWith(qualifier.proposal.toString()))
          {
            // Derive cursor position
            int cursor = text.length();

            IContextInformation contextInfo = new ContextInformation(null, text);
            // Construct proposal
            CompletionProposal proposal = new CompletionProposal(text, documentOffset
                - qlen, qlen, cursor, null, text, contextInfo, text
                + "-Monitored variable declared in contract. "
                + var.getDataType());

            // and add to result list
            propList.add(proposal);
          }
        }

        for (IVariable var : model.getContract().getControlledVariables())
        {

          String text = var.getName();
          if (qualifier.proposal.toString().trim().length() == 0
              || text.startsWith(qualifier.proposal.toString()))
          {
            // Derive cursor position
            int cursor = text.length();

            IContextInformation contextInfo = new ContextInformation(null, text);
            // Construct proposal
            CompletionProposal proposal = new CompletionProposal(text, documentOffset
                - qlen, qlen, cursor, null, text, contextInfo, text
                + "-Monitored variable declared in contract. "
                + var.getDataType());

            // and add to result list
            propList.add(proposal);
          }
        }

      }
    }

    if (qualifier.postEqual && !qualifier.dot)
    {
      for (String text : vdmMetadata.keySet())
      {
        if (qualifier.proposal.toString().trim().length() == 0
            || text.startsWith(qualifier.proposal.toString()))
        {
          int cursor = text.length();
          IContextInformation contextInfo = new ContextInformation(null, text);
          // Construct proposal
          CompletionProposal proposal = new CompletionProposal(text, documentOffset
              - qlen, qlen, cursor, null, text, contextInfo, text
              + "-instance variable in System");
          // and add to result list
          propList.add(proposal);
        }
      }
    }
    if (qualifier.postEqual && qualifier.dot)
    {
      // String prefix = qualifier.substring(0, qualifier.indexOf('.')).trim();
      String pre = qualifier.pre.substring(0, qualifier.pre.length() - 1);
      if (vdmMetadata.containsKey(pre))
      {
        prop.addAll(vdmMetadata.get(pre));
      }
    }

    for (String text : prop)
    {
      if (qualifier.proposal.toString().trim().length() == 0
          || text.startsWith(qualifier.proposal.toString()))
      {
        // Derive cursor position
        int cursor = text.length();
        // Construct proposal
        CompletionProposal proposal = new CompletionProposal(text, documentOffset
            - qlen, qlen, cursor);

        // and add to result list
        propList.add(proposal);
      }
View Full Code Here

        // Derive cursor position
        int cursor = text.length();

        IContextInformation contextInfo = new ContextInformation(null, text);
        // Construct proposal
        CompletionProposal proposal = new CompletionProposal(text, documentOffset
            - qlen, qlen, cursor, null, text, contextInfo, text
            + "-Event declared in contract");

        // and add to result list
        propList.add(proposal);
View Full Code Here

        List<ICompletionProposal> proposalList = new ArrayList<ICompletionProposal>();
        for ( int k = 0; k < possibleAttributeTypes.length; k++ )
        {
            if ( possibleAttributeTypes[k].toUpperCase().startsWith( attribute.toUpperCase() ) )
            {
                ICompletionProposal proposal = new CompletionProposal( possibleAttributeTypes[k] + ", ", start,
                    documentOffset - start, possibleAttributeTypes[k].length() + 2, null, possibleAttributeTypes[k],
                    null, null );
                proposalList.add( proposal );
            }
        }
View Full Code Here

                    }
                }

                for ( int k = 0; k < this.possibleAttributeTypes.length; k++ )
                {
                    ICompletionProposal proposal = new CompletionProposal( this.possibleAttributeTypes[k], offset, 0,
                        this.possibleAttributeTypes[k].length() );
                    proposalList.add( proposal );
                }
            }
            else if ( filter.getFilterComponent() instanceof LdapFilterItemComponent
                && filter.getFilterComponent().getStartToken().getOffset() <= offset
                && offset <= filter.getFilterComponent().getStartToken().getOffset()
                    + filter.getFilterComponent().getStartToken().getLength() )
            {
                // show matching attribute types
                LdapFilterItemComponent fc = ( LdapFilterItemComponent ) filter.getFilterComponent();
                for ( int k = 0; k < this.possibleAttributeTypes.length; k++ )
                {
                    if ( this.possibleAttributeTypes[k].startsWith( fc.getAttributeToken().getValue() ) )
                    {
                        ICompletionProposal proposal = new CompletionProposal( this.possibleAttributeTypes[k], fc
                            .getAttributeToken().getOffset(), fc.getAttributeToken().getLength(),
                            this.possibleAttributeTypes[k].length() );
                        proposalList.add( proposal );
                    }
                }
View Full Code Here

            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 = "";

                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 = schema.getAttributeTypeDescriptionNames();
                    Arrays.sort( attributeNames );
                    for ( int a = 0; a < attributeNames.length; a++ )
                    {
                        if ( rawAttributeDescription.length() == 0
                            || attributeNames[a].toLowerCase().startsWith( rawAttributeDescription.toLowerCase() ) )
                        {

                            String proposal = attributeNames[a];

                            if ( rawValueType.length() == 0 )
                            {
                                if ( schema.getAttributeTypeDescription( proposal ).isBinary() )
                                {
                                    proposal += ":: ";
                                }
                                else
                                {
                                    proposal += ": ";
                                }
                            }

                            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(
                LdifEditorConstants.IMG_LDIF_COMMENT ), "# - Comment", null, null ) );
        }

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

            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 = "";

                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 = schema.getAttributeTypeDescriptionNames();
                    Arrays.sort( attributeNames );
                    for ( int a = 0; a < attributeNames.length; a++ )
                    {
                        if ( rawAttributeDescription.length() == 0
                            || attributeNames[a].startsWith( rawAttributeDescription ) )
                        {

                            String proposal = attributeNames[a];

                            if ( rawValueType.length() == 0 )
                            {
                                if ( schema.getAttributeTypeDescription( proposal ).isBinary() )
                                {
                                    proposal += ":: ";
                                }
                                else
                                {
                                    proposal += ": ";
                                }
                            }

                            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(
                LdifEditorConstants.IMG_LDIF_COMMENT ), "# - Comment", null, null ) );
        }

        // adjust auto-insert
        this.contentAssistant.enableAutoInsert( !commentOnly );
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.