Package org.eclipse.jface.text.templates

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


    boolean setSelection = false;
    String templateName = XMLUIPlugin.getDefault().getPreferenceStore().getString(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME);
    if (templateName == null || templateName.length() == 0) {
      templateName = XMLUIPlugin.getDefault().getPreferenceStore().getString(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_ID);
      if (templateName != null && templateName.length() > 0) {
        Template template = fTemplateStore.findTemplateById(templateName);
        if (template != null) {
          fLastSelectedTemplateName = template.getName();
          setSelection = true;
        }
      }
    }
    else {
View Full Code Here


   * Save template name used for next call to New XML File wizard.
   */
  void saveLastSavedPreferences() {
    String templateName = ""; //$NON-NLS-1$

    Template template = getSelectedTemplate();
    if (template != null) {
      templateName = template.getName();
    }

    XMLUIPlugin.getDefault().getPreferenceStore().setValue(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
    XMLUIPlugin.getDefault().savePluginPreferences();
  }
View Full Code Here

  /**
   * Updates the pattern viewer.
   */
  void updateViewerInput() {
    Template template = getSelectedTemplate();
    if (template != null) {
      fPatternViewer.getDocument().set(template.getPattern());
    }
    else {
      fPatternViewer.getDocument().set(""); //$NON-NLS-1$
    }
  }
View Full Code Here

    /*
     * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
     *      int)
     */
    public String getColumnText(Object element, int columnIndex) {
      Template template = (Template) element;

      switch (columnIndex) {
        case 0 :
          return template.getName();
        case 1 :
          return template.getDescription();
        default :
          return ""; //$NON-NLS-1$
      }
    }
View Full Code Here

    if(contextTypeId.equals(componentsContextTypeId)){
      for(int i=0; i< this.getLength(); i++){
        CMNode node = this.item(i);
        if(node instanceof ElemDecl){
          ElemDecl element = (ElemDecl) node;
          Template template = new Template(element.getElementLabel(), buildDescription(element), contextTypeId, buildInsertCode(element, type), true);
          result.add(template);
        }
      }
    }
    return (Template[])result.toArray(new Template[0]);
View Full Code Here

      ElemDecl element = (ElemDecl) node;
      CMNamedNodeMap attributes = element.getAttributes();
      Iterator ite = attributes.iterator();
      while(ite.hasNext()){
        CMNode attr = (CMNode) ite.next();
        Template template = new Template(attr.getNodeName(), buildAttributeDescription(attr, element), contextTypeId, buildAttributeInsertCode(attr), true);
        result.add(template);
      }
    }
    return (Template[])result.toArray(new Template[0]);
  }
View Full Code Here

   
    Template[] templates = getTemplates((IDOMNode) treeNode, offset, context.getContextType().getId(), preChar, preChar2);

    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())) {
        int place = getRelevance(template, prefix);
        matches.add(createProposal(template, context, (IRegion) region, place));
      }
    }
View Full Code Here

        tapestryTemplates = collection.getAttributeValueList(contextTypeId, currentTapestryComponent);
      }
      return tapestryTemplates == null ? null : tapestryTemplates.toArray(new Template[0]);
    }
    else{
      Template templates[] = null;
      TemplateStore store = getTemplateStore();
      if (store != null) {
        templates = store.getTemplates(contextTypeId);
      }
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

      Node root= document.createElement(TEMPLATE_ROOT);
      document.appendChild(root);

      for (int i= 0; i < templates.length; i++) {
        TemplatePersistenceData data= templates[i];
        Template template= data.getTemplate();

        Node node= document.createElement(TEMPLATE_ELEMENT);
        root.appendChild(node);

        NamedNodeMap attributes= node.getAttributes();

        String id= data.getId();
        if (id != null) {
          Attr idAttr= document.createAttribute(ID_ATTRIBUTE);
          idAttr.setValue(id);
          attributes.setNamedItem(idAttr);
        }

        if (template != null) {
          Attr name= document.createAttribute(NAME_ATTRIBUTE);
          name.setValue(template.getName());
          attributes.setNamedItem(name);
        }

        if (template != null) {
          Attr description= document.createAttribute(DESCRIPTION_ATTRIBUTE);
          description.setValue(template.getDescription());
          attributes.setNamedItem(description);
        }

        if (template != null) {
          Attr context= document.createAttribute(CONTEXT_ATTRIBUTE);
          context.setValue(template.getContextTypeId());
          attributes.setNamedItem(context);
        }

        Attr enabled= document.createAttribute(ENABLED_ATTRIBUTE);
        enabled.setValue(data.isEnabled() ? Boolean.toString(true) : Boolean.toString(false));
        attributes.setNamedItem(enabled);

        Attr deleted= document.createAttribute(DELETED_ATTRIBUTE);
        deleted.setValue(data.isDeleted() ? Boolean.toString(true) : Boolean.toString(false));
        attributes.setNamedItem(deleted);

        if (template != null) {
          Attr autoInsertable= document.createAttribute(AUTO_INSERTABLE_ATTRIBUTE);
          autoInsertable.setValue(template.isAutoInsertable() ? Boolean.toString(true) : Boolean.toString(false));
          attributes.setNamedItem(autoInsertable);
        }

        if (template != null) {
          Text pattern= document.createTextNode(template.getPattern());
          node.appendChild(pattern);
        }
      }

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.