Examples of CustomCompletionProposal


Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

  /**
   * @deprecated XML proposal is added via xml declaration template instead
   */
  protected void addXMLProposal(ContentAssistRequest contentAssistRequest) {
    String proposedText = "<?xml version=\"1.0\" encoding=\"" + ContentTypeEncodingPreferences.getUserPreferredCharsetName(ContentTypeIdForXML.ContentTypeID_XML) + "\"?>"; //$NON-NLS-2$//$NON-NLS-1$
    ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION), proposedText, null, null, XMLRelevanceConstants.R_XML_DECLARATION);
    // TODO add special XML proposal info
    contentAssistRequest.addProposal(proposal);
  }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

          proposedText = "/" + tagName; //$NON-NLS-1$
        }
      }

      // create proposal
      p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
            documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG);
    }
    else if (!hasEndTag && isJSPTag) {

      // create appropriate close tag text
      String proposedText = "%"; //$NON-NLS-1$
      String viewerText = viewer.getTextWidget().getText();

      // TODO (pa) make it smarter to add "%>" or just ">" if % is
      // already there...
      if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2)) {
        String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
        String lastchar = viewerText.substring(documentPosition - 1, documentPosition);
        if (lastchar.equals("%")) //$NON-NLS-1$
        {
          if (last2chars.endsWith("<%")) {
            proposedText = "%"; //$NON-NLS-1$
          }
          else {
            proposedText = ""; //$NON-NLS-1$
          }
        }
      }

      // create proposal
      p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
            documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG);
    }

    return p;
  }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

          proposedText = "/" + tagName; //$NON-NLS-1$
        }
      }

      // create proposal
      p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
            documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG);
    }
    return p;
  }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

              }
            }

            String proposedText = null;
            String proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
            CustomCompletionProposal proposal = null;
            // attribute is at this location and already exists
            if (attrAtLocationHasValue) {
              // only propose the name
              proposedText = getRequiredName(node, attrDecl);
              proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true);
            }
            // no attribute exists or is elsewhere, generate
            // minimally
            else {
              Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
              String value = null;
              if (existingAttrNode != null && existingAttrNode.getSpecified()) {
                value = existingAttrNode.getNodeValue();
              }
              if ((value != null) && (value.length() > 0)) {
                proposedText = getRequiredName(node, attrDecl);
              }
              else {
                proposedText = getRequiredText(node, attrDecl);
              }
              proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), attrDecl.getNodeName().length() + 2, attrImage,
              // if the value isn't empty (no empty set of
                    // quotes), show it
              // BUG 203494, content strings may have "", but not be empty
              // An empty string is when there's no content between double quotes
              // and there is no single quote that may be encasing a double quote
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

              String possibleValue = (String) j.next();
              if(!possibleValue.equals(defaultValue)) {
                currentValid = currentValid || possibleValue.equals(currentValue);
                if ((matchString.length() == 0) || possibleValue.startsWith(matchString)) {
                  String rString = "\"" + possibleValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
                  CustomCompletionProposal proposal = new CustomCompletionProposal(rString, rOffset, rLength, possibleValue.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM), rString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
                  contentAssistRequest.addProposal(proposal);
                }
              }
            }
            if(defaultValue != null && ((matchString.length() == 0) || defaultValue.startsWith(matchString))) {
              String rString = "\"" + defaultValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
              CustomCompletionProposal proposal = new CustomCompletionProposal(rString, rOffset, rLength, defaultValue.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DEFAULT), rString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
              contentAssistRequest.addProposal(proposal);
            }
          }
        }
        else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrDecl.getAttrType().getImpliedValue() != null)) {
          // FIXED values
          String value = attrDecl.getAttrType().getImpliedValue();
          if ((value != null) && (value.length() > 0)) {
            String rValue = "\"" + value + "\"";//$NON-NLS-2$//$NON-NLS-1$
            CustomCompletionProposal proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
            contentAssistRequest.addProposal(proposal);
            if ((currentValue.length() > 0) && !value.equals(currentValue)) {
              rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
              proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
              contentAssistRequest.addProposal(proposal);
            }
          }
        }
      }
      else {
        // unknown attribute, so supply nice empty values
        proposedInfo = getAdditionalInfo(null, elementDecl);
        CustomCompletionProposal proposal = null;
        if ((currentValue != null) && (currentValue.length() > 0)) {
          String rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
          proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
          contentAssistRequest.addProposal(proposal);
        }
      }
    }
    else {
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

      setErrorMessage(UNKNOWN_CONTEXT);
    }
  }

  protected void addCommentProposal(ContentAssistRequest contentAssistRequest) {
    contentAssistRequest.addProposal(new CustomCompletionProposal("<!--  -->", //$NON-NLS-1$
          contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 5, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_COMMENT), NLS.bind(XMLUIMessages.Comment__, (new Object[]{" <!--  -->"})), //$NON-NLS-1$
          null, null, XMLRelevanceConstants.R_COMMENT));
  }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

    if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null) {
      rootname = contentAssistRequest.getNode().getOwnerDocument().getDocumentElement().getNodeName();
    }

    String proposedText = "<!DOCTYPE " + rootname + " PUBLIC \"//UNKNOWN/\" \"unknown.dtd\">"; //$NON-NLS-1$ //$NON-NLS-2$
    ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 10, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DOCTYPE), "<!DOCTYPE ... >", //$NON-NLS-1$
          null, null, XMLRelevanceConstants.R_DOCTYPE);
    // TODO provide special documentation on doc type
    contentAssistRequest.addProposal(proposal);
  }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

   * Add the proposals for the name in an end tag
   */
  protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest) {

    if (contentAssistRequest.getStartOffset() + contentAssistRequest.getRegion().getTextLength() < contentAssistRequest.getReplacementBeginPosition()) {
      CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
            contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
            null, null, XMLRelevanceConstants.R_END_TAG_NAME);
      contentAssistRequest.addProposal(proposal);
    }
    else {
      IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
      ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
      Node aNode = contentAssistRequest.getNode();
      String matchString = contentAssistRequest.getMatchString();
      if (matchString.startsWith("</")) {
        matchString = matchString.substring(2);
      }
      while (aNode != null) {
        if (aNode.getNodeType() == Node.ELEMENT_NODE) {
          if (aNode.getNodeName().startsWith(matchString)) {
            IDOMNode aXMLNode = (IDOMNode) aNode;
            CMElementDeclaration ed = modelQuery.getCMElementDeclaration((Element) aNode);
            if ((aXMLNode.getEndStructuredDocumentRegion() == null) && ((ed == null) || (ed.getContentType() != CMElementDeclaration.EMPTY))) {
              String replacementText = aNode.getNodeName();
              String displayText = replacementText;
              String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
              if(!contentAssistRequest.getDocumentRegion().isEnded()) {
                replacementText += ">"; //$NON-NLS-1$
              }
              CustomCompletionProposal proposal = null;
              // double check to see if the region acted upon is
              // a tag name; replace it if so
              Image image = CMImageUtil.getImage(ed);
              if (image == null) {
                image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
              }
              if (contentAssistRequest.getRegion().getType() == DOMRegionContext.XML_TAG_NAME) {
                proposal = new CustomCompletionProposal(replacementText, contentAssistRequest.getStartOffset(), contentAssistRequest.getRegion().getTextLength(), replacementText.length(), image, displayText, null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
              }
              else {
                proposal = new CustomCompletionProposal(replacementText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), replacementText.length(), image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{"'" + displayText + "'"})), //$NON-NLS-1$ //$NON-NLS-2$
                      null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
              }
              contentAssistRequest.addProposal(proposal);
            }
          }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

    // ////////////////////////////////////////////////////////////////////////////////////
    else if (node.getNodeType() == Node.DOCUMENT_NODE) {
      setErrorMessage(UNKNOWN_CONTEXT);
    }
    if (addProposal == true) {
      CustomCompletionProposal proposal = new CustomCompletionProposal(replaceText, replaceBegin, replaceLength, cursorOffset, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_END_TAG);
      contentAssistRequest.addProposal(proposal);
    }
  }
View Full Code Here

Examples of org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal

          selectionLength += fTextViewer.getSelectedRange().y;
        }
        // create a new proposal for entity string...
        replacementText = "&" + entityName + ";"; //$NON-NLS-1$ //$NON-NLS-2$
        displayString = "&" + entityName + "; (" + entityValue + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        ICompletionProposal cp = new CustomCompletionProposal(replacementText, sdRegion.getStartOffset(completionRegion), selectionLength, replacementText.length(), entityIcon, displayString, null, null, XMLRelevanceConstants.R_ENTITY);
        if (cp != null) {
          proposals.add(cp);
        }
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.