Package org.eclipse.jface.text.templates

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


  public Template findTemplate(String name, String contextTypeId) {
    Assert.isNotNull(name);

    for (Iterator it= fTemplates.iterator(); it.hasNext();) {
      TemplatePersistenceData data= (TemplatePersistenceData) it.next();
      Template template= data.getTemplate();
      if (data.isEnabled() && !data.isDeleted()
          && (contextTypeId == null || contextTypeId.equals(template.getContextTypeId()))
          && name.equals(template.getName()))
        return template;
    }

    return null;
  }
View Full Code Here


    }
    try {
      if (description == null)
        description = "";

      Template template = new Template(name, description,
          QVTContextType.QVT_CONTEXT_TYPE, pattern, true);
      TemplateProposal proposal = new TemplateProposal(template, context,
          region, image_id, getRelevance(template, prefix));
      return proposal;
    } catch (Exception e) {
View Full Code Here

  private TemplateProposal createHelperProposal(IRegion region) {
    Image image_id = UiPlugin.getImage(UiPlugin.IMAGE_OPERATION);
    String pattern = "helper ${type_in}::" + prefix
        + "(${}) : ${type_out}{\n"
        + "\t-- Auto-generated method stub\n\t${cursor}\n}";
    Template template = new Template(prefix, "Method Stub",
        QVTContextType.QVT_CONTEXT_TYPE, pattern, false);
    TemplateProposal proposal = new TemplateProposal(template, context,
        region, image_id, getRelevance(template, prefix));
    return proposal;
  }
View Full Code Here

    templatePreview.getTextWidget().setLayoutData( previewData );

    //initialize description and preview
    try {
      int templateSelectedIndex = templateCombo.getSelectionIndex();
      Template templateSelected = newFileTemplates
          .get( templateSelectedIndex );

      templateDescription.setText( templateSelected.getDescription() );
      templatePreview.getDocument().set( templateSelected.getPattern() );
    } catch ( IndexOutOfBoundsException e ) {
    }

    //mg------------------------

    initialize();
    setPageComplete(false);

    ModifyTextListner listener = new ModifyTextListner();
    containerText.addModifyListener(listener);
    moduleText.addModifyListener(listener);

    //mg
    briefText.addModifyListener( listener );
    templateCombo.addSelectionListener( new SelectionListener() {

      public void widgetSelected( SelectionEvent e ) {

        try {
          final Template templateSelected = getTemplate();

          templateDescription.setText( templateSelected
              .getDescription() );
          templatePreview.getDocument().set( templateSelected.getPattern() );
        } catch ( Exception exception ) {
        }
      }

      public void widgetDefaultSelected( SelectionEvent e ) {
View Full Code Here

    Region region = null;
    Image image;
    int relevance = 0;
    TemplateWithIndent templateX = null;
    DocumentTemplateContext context = null;
    Template template = null;

    image = VerilogPlugin.getPlugin().getImage(m_Element.GetImageName());
    context = new DocumentTemplateContext(new VhdlGlobalContext(), m_Doc,
        m_Offset, m_Length);
    //set the region to cover the text begin replaced
    region = new Region(m_Offset, m_Length);

    template = new Template(
        m_Element.getShortName(),
          getDescription(),
          VhdlGlobalContext.CONTEXT_TYPE,
        getString(),
        false);
View Full Code Here

      TemplateContextType contextType=VerilogPlugin.getPlugin().getContextTypeRegistry().getContextType(contextString);
      Template[] templates= VerilogPlugin.getPlugin().getTemplateStore().getTemplates(contextType.getId());
      DocumentTemplateContext documnetTemplateContext= new DocumentTemplateContext(contextType, doc, region.getOffset(), region.getLength());
      //find a matching template
      for (int i= 0; i < templates.length; i++) {
        Template template= templates[i];
        String pattern = template.getPattern();
        pattern = pattern.replace("\t", indentationstring);
        pattern = pattern.replace("\r", "");
        pattern = pattern.replace("\n", eol);
        template.setPattern(pattern);
       
        try {
          contextType.validate(template.getPattern());
        } catch (TemplateException e) {
          continue;
        }     
       
        if (template.matches(prefix, contextType.getId()) && template.getName().startsWith(prefix)){
          String indent = doc.getIndentString(offset);
          template = new TemplateWithIndent(template, indent);
          HdlTemplateProposal hdlTemplateProposal=new HdlTemplateProposal(template,
                                documnetTemplateContext,
                                region,
View Full Code Here

  protected void updateViewerInput() {
    IStructuredSelection selection= (IStructuredSelection) getTableViewer().getSelection();

    if (selection.size() == 1) {
      TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
      Template template= data.getTemplate();
      if(template.getContextTypeId().contains("vhdl"))
      {
        getViewer().unconfigure();
        SourceViewerConfiguration configuration= HdlSourceViewerConfiguration.createForVhdl(new VerilogEditor());
        getViewer().configure(configuration);
       
       
      }
      else if(template.getContextTypeId().contains("verilog"))
      {
        getViewer().unconfigure();
        SourceViewerConfiguration configuration= HdlSourceViewerConfiguration.createForVerilog(new VhdlEditor());
        getViewer().configure(configuration);
      }
View Full Code Here

    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 (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

  public Template findTemplate(String name, String contextTypeId) {
    Assert.isNotNull(name);

    for (Iterator it= fTemplates.iterator(); it.hasNext();) {
      TemplatePersistenceData data= (TemplatePersistenceData) it.next();
      Template template= data.getTemplate();
      if (data.isEnabled() && !data.isDeleted()
          && (contextTypeId == null || contextTypeId.equals(template.getContextTypeId()))
          && name.equals(template.getName()))
        return template;
    }

    return null;
  }
View Full Code Here

            buffer.append(value);
        }
        String pattern= buffer.toString();
        pattern= translateString(pattern, bundle);

        Template template= new Template(name, description, context, pattern, autoInsertable);
        TemplatePersistenceData data= new TemplatePersistenceData(template, enabled, id);
        data.setDeleted(deleted);

        templates.add(data);
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.templates.Template

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.