Examples of TemplateContext


Examples of org.apache.shindig.gadgets.templates.TemplateContext

  protected Document result;

  @Before
  public void setUp() throws Exception {
    processor = new MyTemplateProcessor();
    processor.context = new TemplateContext(gadget, Collections.<String, JSONObject>emptyMap());
    Injector injector = Guice.createInjector(new ParseModule(), new PropertiesModule());
    documentProvider = injector.getInstance(DOMImplementation.class);
    parser = injector.getInstance(NekoSimplifiedHtmlParser.class);
    featureRegistry = mock(FeatureRegistry.class, true);
    handler = new FlashTagHandler(new BeanJsonConverter(injector), featureRegistry,
View Full Code Here

Examples of org.apache.synapse.mediators.template.TemplateContext

                    return ((Axis2MessageContext)
                        synCtx).getAxis2MessageContext().getProperty(localName);

                } else if (SynapseXPathConstants.FUNC_CONTEXT_VARIABLE_PREFIX.equals(prefix)) {
                    Stack<TemplateContext> functionStack = (Stack) synCtx.getProperty(SynapseConstants.SYNAPSE__FUNCTION__STACK);
                    TemplateContext topCtxt = functionStack.peek();
                    if (topCtxt != null) {
                        Object result = topCtxt.getParameterValue(localName);
                        if (result != null && result instanceof SynapseXPath && env != null) {
                            SynapseXPath expression = (SynapseXPath) topCtxt.getParameterValue(localName);
                            try {
                                return expression.evaluate(env);
                            } catch (JaxenException e) {
                                return null;
                            }
View Full Code Here

Examples of org.apache.synapse.mediators.template.TemplateContext

                    = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
            return axis2MessageContext.getProperty(key);

        } else if (XMLConfigConstants.SCOPE_FUNC.equals(scope)) {
            Stack<TemplateContext> functionStack = (Stack) synCtx.getProperty(SynapseConstants.SYNAPSE__FUNCTION__STACK);
            TemplateContext topCtxt = functionStack.peek();
            if (topCtxt!=null) {
                return topCtxt.getParameterValue(key);
            }
        } else if (XMLConfigConstants.SCOPE_TRANSPORT.equals(scope)
                && synCtx instanceof Axis2MessageContext) {

            org.apache.axis2.context.MessageContext axis2MessageContext
View Full Code Here

Examples of org.apache.synapse.mediators.template.TemplateContext

                    = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
            return axis2MessageContext.getProperty(key);

        } else if (XMLConfigConstants.SCOPE_FUNC.equals(scope)) {
            Stack<TemplateContext> functionStack = (Stack) synCtx.getProperty(SynapseConstants.SYNAPSE__FUNCTION__STACK);
            TemplateContext topCtxt = functionStack.peek();
            if (topCtxt!=null) {
                return topCtxt.getParameterValue(key);
            }
        } else if (XMLConfigConstants.SCOPE_TRANSPORT.equals(scope)
                && synCtx instanceof Axis2MessageContext) {

            org.apache.axis2.context.MessageContext axis2MessageContext
View Full Code Here

Examples of org.eclipse.jface.text.templates.TemplateContext

    }

    @Override
    public String getAdditionalProposalInfo() {
        try {
            final TemplateContext context = getContext();
            context.setReadOnly(true);
            TemplateBuffer templateBuffer;
            try {
                final Template template = getTemplate();
                if (context instanceof ErlangTemplateContext) {
                    final ErlangTemplateContext etc = (ErlangTemplateContext) context;
                    templateBuffer = etc.evaluate(template, true);
                } else {
                    templateBuffer = context.evaluate(template);
                }
            } catch (final TemplateException e) {
                return null;
            }
            return templateBuffer.getString();
View Full Code Here

Examples of org.eclipse.jface.text.templates.TemplateContext

    if (selection.getOffset() == offset)
      offset= selection.getOffset() + selection.getLength();

    String prefix= extractPrefix(viewer, offset);
    Region region= new Region(offset - prefix.length(), prefix.length());
    TemplateContext context= createContext(viewer, region);
    if (context == null)
      return new ICompletionProposal[0];

    context.setVariable("selection", selection.getText()); // name of the selection variables {line, word}_selection //$NON-NLS-1$

    Template[] templates= getTemplates(context.getContextType().getId());

    List matches= new ArrayList();
    for (int i= 0; i < templates.length; i++) {
      Template template= templates[i];
      try {
        context.getContextType().validate(template.getPattern());
      } catch (TemplateException e) {
        continue;
      }
      if (template.getName().startsWith(prefix) &&
          template.matches(prefix, context.getContextType().getId()))
        matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
    }

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

Examples of org.eclipse.jface.text.templates.TemplateContext

    if (selection.getOffset() == offset)
      offset= selection.getOffset() + selection.getLength();
    String prefix = extractPrefix(viewer, offset);
   
    Region region = new Region(offset - prefix.length(), prefix.length());
    TemplateContext context = createContext(viewer, region);
    if (context == null)
      return new ICompletionProposal[0];
    context.setVariable("selection", selection.getText()); // name of the selection variables {line, word_selection //$NON-NLS-1$
   
    Template[] templates = getTemplates(context.getContextType().getId());
    List<ICompletionProposal> matches = new ArrayList<ICompletionProposal>();
    for (int i= 0; i < templates.length; i++) {
      Template template= templates[i];
      try {
        context.getContextType().validate(template.getPattern());
      } catch (TemplateException e) {
        continue;
      }
      if(!prefix.equals("") &&prefix.charAt(0)=='<')
        prefix = prefix.substring(1);
      if (!prefix.equals("")&&(template.getName().startsWith(prefix) &&
          template.matches(prefix, context.getContextType().getId())))
        matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
    }
    return matches.toArray(new ICompletionProposal[matches.size()]);
  }
View Full Code Here

Examples of org.eclipse.jface.text.templates.TemplateContext

    if (selection.getOffset() == offset)
      offset= selection.getOffset() + selection.getLength();
    String prefix = extractPrefix(viewer, offset);
   
    Region region = new Region(offset - prefix.length(), prefix.length());
    TemplateContext context = createContext(viewer, region);
    if (context == null)
      return new ICompletionProposal[0];
    context.setVariable("selection", selection.getText()); // name of the selection variables {line, word_selection //$NON-NLS-1$
   
    Template[] templates = getTemplates(context.getContextType().getId());
    List<ICompletionProposal> matches = new ArrayList<ICompletionProposal>();
    for (int i= 0; i < templates.length; i++) {
      Template template= templates[i];
      try {
        context.getContextType().validate(template.getPattern());
      } catch (TemplateException e) {
        continue;
      }
      if(!prefix.equals("") &&prefix.charAt(0)=='<')
        prefix = prefix.substring(1);
      if (!prefix.equals("")&&(template.getName().startsWith(prefix) &&
          template.matches(prefix, context.getContextType().getId())))
        matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
    }
    return matches.toArray(new ICompletionProposal[matches.size()]);
  }
View Full Code Here

Examples of org.eclipse.jface.text.templates.TemplateContext

    Template template = getSelectedTemplate();
    if (template != null) {
      TemplateContextType contextType = JSPUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsJSP.NEW_TAG);
      IDocument document = new Document();
      TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
      try {
        TemplateBuffer buffer = context.evaluate(template);
        templateString = buffer.getString();
      }
      catch (Exception e) {
        Logger.log(Logger.WARNING_DEBUG, "Could not create template for new jsp tag", e); //$NON-NLS-1$
      }
View Full Code Here

Examples of org.eclipse.jface.text.templates.TemplateContext

    if (selection.getOffset() == offset)
      offset = selection.getOffset() + selection.getLength();

    String prefix = extractPrefix(viewer, offset);
    Region region = new Region(offset - prefix.length(), prefix.length());
    TemplateContext context = createContext(viewer, region, offset);
    if (context == null)
      return new ICompletionProposal[0];

    // name of the selection variables {line, word}_selection
    context.setVariable("selection", selection.getText()); // //$NON-NLS-1$

    Template[] templates = getTemplates(context.getContextType().getId());

    List matches = new ArrayList();
    for (int i = 0; i < templates.length; i++) {
      Template template = templates[i];
      try {
        context.getContextType().validate(template.getPattern());
      }
      catch (TemplateException e) {
        continue;
      }
      if (template.matches(prefix, context.getContextType().getId()))
        matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
    }

    Collections.sort(matches, fgProposalComparator);
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.