Package org.eclipse.xtext.ui.editor.contentassist

Examples of org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal


    switch (prop.getType()) {
    case BOOLEAN: {
      ICompletionProposal p = createCompletionProposal("true", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }

      acceptor.accept(p);

      p = createCompletionProposal("false", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }

      acceptor.accept(p);
      break;
    }
    case BYTE:
    case CHAR:
    case INTEGER:
    case LONG:
    case SHORT: {
      ICompletionProposal p = createCompletionProposal("1", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }
      acceptor.accept(p);
      break;
    }
    case DOUBLE:
    case FLOAT: {
      ICompletionProposal p = createCompletionProposal("1.0", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }
      acceptor.accept(p);
      break;
    }
    case STRING: {
      ICompletionProposal p = createCompletionProposal("\"<String>\"", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }
      acceptor.accept(p);
      break;
    }
    default:
View Full Code Here


        for (IField f : t.getFields()) {
          if (Flags.isEnum(f.getFlags())) {
            ICompletionProposal p = createCompletionProposal("\"" + f.getElementName() + "\"", new StyledString(f.getElementName()).append(" - " + prop.getEnumTypeAsString(false), StyledString.QUALIFIER_STYLER), IconKeys.getIcon(IconKeys.ENUM_KEY), getPriorityHelper()
                .getDefaultPriority(), "\"" + context.getPrefix(), context);
            if (p instanceof ConfigurableCompletionProposal) {
              ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
              cp.setAdditionalProposalInfo(model);
              cp.setHover(new HoverImpl(f));
            }

            acceptor.accept(p);
          }
        }
View Full Code Here

    String type = prop.getElementTypeAsString(true);
   
    if( "java.lang.Boolean".equals(type) ) {
      ICompletionProposal p = createCompletionProposal("true", context);
      if( p instanceof ConfigurableCompletionProposal ) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getValueOfMethod()));
      }
      acceptor.accept(p);
     
      p = createCompletionProposal("false", context);
      if( p instanceof ConfigurableCompletionProposal ) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getValueOfMethod()));
      }
      acceptor.accept(p);
    } else if(isIntegerType(type)) {
      ICompletionProposal p = createCompletionProposal("1", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }
      acceptor.accept(p);
    } else if(isDoubleType(type)) {
      ICompletionProposal p = createCompletionProposal("1.0", context);

      if (p instanceof ConfigurableCompletionProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
        cp.setAdditionalProposalInfo(model);
        cp.setHover(new HoverImpl(prop.getJavaElement()));
      }
      acceptor.accept(p);
    } else {
      if (prop.hasValueOf()) {
        ICompletionProposal p = createCompletionProposal("\"\"", new StyledString("\"<String>\""), null, getPriorityHelper().getDefaultPriority() + 1, context.getPrefix(), context);
       
        if( p instanceof ConfigurableCompletionProposal ) {
          ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
          cp.setAdditionalProposalInfo(model);
          cp.setHover(new HoverImpl(prop.getValueOfMethod()));
        }
       
        acceptor.accept(p);
       
        for( IValueOfContributor contrib : valueOfCollector.getContributors(prop.getElementTypeAsString(true)) ) {
          for( Proposal vProp : contrib.getProposals() ) {
            int prio = getPriorityHelper().getDefaultPriority()  + vProp.getPriority() + 2;
            p = createCompletionProposal("\""+vProp.getValue()+"\"", new StyledString(vProp.getValue()), IconKeys.getIcon(IconKeys.VALUE_OF_KEY),prio , "\""+context.getPrefix(), context);
           
            if( p instanceof ConfigurableCompletionProposal ) {
              if( vProp instanceof DialogProposal ) {
                ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) p;
                final DialogProposal dProp = (DialogProposal) vProp;
                cp.setTextApplier(new ReplacementTextApplier() {
                  @Override
                  public String getActualReplacementString(
                      ConfigurableCompletionProposal proposal) {
                    return "\"" + dProp.openDialogValue() + "\"";
                  }
View Full Code Here

              String type = cp.getElementType().getElementName();
              if( "String".equals(type) ) {
                ICompletionProposal p = createCompletionProposal("\"\"", new StyledString("\"<String>\""), IconKeys.getIcon(IconKeys.CLASS_KEY), context);
             
                if (p instanceof ConfigurableCompletionProposal) {
                  ConfigurableCompletionProposal ccp = (ConfigurableCompletionProposal) p;
                  ccp.setAdditionalProposalInfo(listProp);
                  ccp.setHover(new HoverImpl(ownerProperty.getJavaElement()));
                  ccp.setCursorPosition(ccp.getCursorPosition() - 1);
                }
                acceptor.accept(p);
              } else if( "Double".equals(type) ) {
                ICompletionProposal p = createCompletionProposal("1.0", context);

                if (p instanceof ConfigurableCompletionProposal) {
                  ConfigurableCompletionProposal ccp = (ConfigurableCompletionProposal) p;
                  ccp.setAdditionalProposalInfo(listProp);
                  ccp.setHover(new HoverImpl(ownerProperty.getJavaElement()));
                }
                acceptor.accept(p);
              } else if( "Integer".equals(type) ) {
                ICompletionProposal p = createCompletionProposal("1", context);

                if (p instanceof ConfigurableCompletionProposal) {
                  ConfigurableCompletionProposal ccp = (ConfigurableCompletionProposal) p;
                  ccp.setAdditionalProposalInfo(listProp);
                  ccp.setHover(new HoverImpl(ownerProperty.getJavaElement()));
                }
                acceptor.accept(p);
              } else if( "Boolean".equals(type) ) {
                ICompletionProposal p = createCompletionProposal("true", context);

                if (p instanceof ConfigurableCompletionProposal) {
                  ConfigurableCompletionProposal ccp = (ConfigurableCompletionProposal) p;
                  ccp.setAdditionalProposalInfo(listProp);
                  ccp.setHover(new HoverImpl(ownerProperty.getJavaElement()));
                }
                acceptor.accept(p);
               
                p = createCompletionProposal("false", context);

                if (p instanceof ConfigurableCompletionProposal) {
                  ConfigurableCompletionProposal ccp = (ConfigurableCompletionProposal) p;
                  ccp.setAdditionalProposalInfo(listProp);
                  ccp.setHover(new HoverImpl(ownerProperty.getJavaElement()));
                }
                acceptor.accept(p);
              } else {
                createCollectionClassProposals(cp, listProp, context, FXGraphPackage.Literals.LIST_VALUE_PROPERTY__VALUE, acceptor);
              }
View Full Code Here

    for (Proposal p : proposals) {
     
      final Image img = labelProvider.getImage(CssDslFactory.eINSTANCE.createcss_property());
     
      if (p instanceof UIProposal) {
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) createCompletionProposal(p.getLabel(), p.getLabel(), img, context);
        final UIProposal uiP = (UIProposal)p;
       
        if (cp != null) {
          cp.setTextApplier(new ReplacementTextApplier() {
            //@Override
            public String getActualReplacementString(ConfigurableCompletionProposal proposal) {
              if (uiP.show()) {
                return uiP.getProposal();
              }
              return "";
            }
          });
          cp.setPriority(p.getPriority());
          acceptor.accept(cp);
        }
      }
      else {
       
        ConfigurableCompletionProposal cp = (ConfigurableCompletionProposal) createCompletionProposal(p.getProposal(), p.getLabel(), img, context);
        if (cp != null) {
          cp.setAdditionalProposalInfo(p.getAdditionalInfo());
          cp.setHover(hoverDispatcher);
         
          cp.setTriggerCharacters(new char[] { ' ' });
         
          if (p.getType() == Type.Property) {
            // add ": " to proposal
            cp.setTextApplier(new IReplacementTextApplier() {
             
              @Override
              public void apply(IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
                document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(), proposal.getReplacementString() + ": ");
                proposal.setCursorPosition(proposal.getCursorPosition()+2);
              }
            });
          }
          if (p.getType() == Type.Value) {
            cp.setTextApplier(new IReplacementTextApplier() {
           
              private int findWSCountBeforeProposal(IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
                // remove spaces " " before proposal
                int offset = 0;
               
                int amount = 10;
                if (proposal.getReplacementOffset() - amount < 0) {
                  amount = proposal.getReplacementOffset();
                }
                String beforeChars = document.get(proposal.getReplacementOffset() - amount, amount);
                Pattern spaces = Pattern.compile("(.*)[ ]+$");
                Matcher m = spaces.matcher(beforeChars);
                if (m.matches()) {
                  System.err.println("REDUCE!! " + m.end(1));
                  offset = amount - m.end(1);
                }
                return offset;
              }
             
              @Override
              public void apply(IDocument document, ConfigurableCompletionProposal proposal) throws BadLocationException {
                if (proposal.getReplacementString().equals(";")) {
                  int wsCount = findWSCountBeforeProposal(document, proposal);
                 
                  document.replace(proposal.getReplacementOffset()-wsCount, proposal.getReplacementLength()+wsCount, proposal.getReplacementString());
                  proposal.setCursorPosition(proposal.getCursorPosition()-wsCount);
                }
                else if (proposal.getReplacementString().equals(",")) {
                  int wsCount = findWSCountBeforeProposal(document, proposal);
                 
                  document.replace(proposal.getReplacementOffset()-wsCount, proposal.getReplacementLength()+wsCount, proposal.getReplacementString() + " ");
                  proposal.setCursorPosition(proposal.getCursorPosition()+1-wsCount);
                }
                else {
                  // add " " to proposal
                  document.replace(proposal.getReplacementOffset(), proposal.getReplacementLength(), proposal.getReplacementString() + " ");
                  proposal.setCursorPosition(proposal.getCursorPosition()+1);
                }
              }
            });
          }
          cp.setPriority(p.getPriority());
         
          acceptor.accept(cp);
        }
        else {
          System.err.println("cound not create proposal for " + p);
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal

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.