Package org.eclipse.jface.text.templates

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


    List<String> componentNameList = getCustomComponentsNameList(roots, cp)
    for(String componentName : componentNameList){
      TapestryCoreComponents component = new TapestryCoreComponents();
      component.setName(componentName);
      component.setElementLabel(cp.getPrefix() + ":" + componentName.toLowerCase());
      templateList.add(new Template(cp.getPrefix() + ":" + component.getName(), buildDescription(component, cp.getPath()), contextTypeId, cp.getPrefix()+ "/" +component.getName(), true));
    }
  }
View Full Code Here


      component.setName(componentName);
      if (prefix == null || prefix.equals("t"))
        component.setElementLabel("t:" + cp.getPrefix() + "." + componentName.toLowerCase());
      else
        component.setElementLabel(cp.getPrefix() + ":" + componentName.toLowerCase());
      templateList.add(new Template(cp.getPrefix() + ":" + component.getName(), buildDescription(component,
          cp.getPath()), contextTypeId, buildInsertCode(component, type), true));
    }
  }
View Full Code Here

     *            a source offset into the parent compilation unit. The template is evaluated at the given source offset
     * @return return the template with the given name or <code>null</code> if the template could not be found.
     */
    protected String getTemplate(String name, ICompilationUnit parentCU, int pos) {
        try {
            Template template = JavaPlugin.getDefault().getTemplateStore().findTemplate(name);
            if (template != null) {
                return JavaContext.evaluateTemplate(template, parentCU, pos);
            }
        } catch (CoreException e) {
            JavaPlugin.log(e);
View Full Code Here

            if (autoInsert == null)
              bAutoInsert= true;
            else
              bAutoInsert= Boolean.valueOf(autoInsert).booleanValue();
           
            Template template= new Template(name, desc, contextTypeId, pattern, bAutoInsert);
            TemplatePersistenceData data= new TemplatePersistenceData(template, true, id);
            if (validateTemplate(template))
              map.add(data);
          }
        }
View Full Code Here

    fTableViewer.setContentProvider(new TemplateContentProvider());

    fTableViewer.setComparator(new ViewerComparator() {
      public int compare(Viewer viewer, Object object1, Object object2) {
        if ((object1 instanceof TemplatePersistenceData) && (object2 instanceof TemplatePersistenceData)) {
          Template left= ((TemplatePersistenceData) object1).getTemplate();
          Template right= ((TemplatePersistenceData) object2).getTemplate();
          int result= left.getName().compareToIgnoreCase(right.getName());
          if (result != 0)
            return result;
          return left.getDescription().compareToIgnoreCase(right.getDescription());
        }
        return super.compare(viewer, object1, object2);
      }

      public boolean isSorterProperty(Object element, String property) {
View Full Code Here

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

    if (selection.size() == 1) {
      TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
      Template template= data.getTemplate();
      fPatternViewer.getDocument().set(template.getPattern());
    } else {
      fPatternViewer.getDocument().set(""); //$NON-NLS-1$
    }
  }
View Full Code Here

  private void add() {

    Iterator it= fContextTypeRegistry.contextTypes();
    if (it.hasNext()) {
      Template template= new Template("", "", ((TemplateContextType) it.next()).getId(), "", true);   //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

      Template newTemplate= editTemplate(template, false, true);
      if (newTemplate != null) {
        TemplatePersistenceData data= new TemplatePersistenceData(newTemplate, true);
        fTemplateStore.add(data);
        fTableViewer.refresh();
        fTableViewer.setChecked(data, true);
View Full Code Here

    TemplatePersistenceData data= (TemplatePersistenceData) selection.getFirstElement();
    edit(data);
  }

  private void edit(TemplatePersistenceData data) {
    Template oldTemplate= data.getTemplate();
    Template newTemplate= editTemplate(new Template(oldTemplate), true, true);
    if (newTemplate != null) {

      if (!newTemplate.getName().equals(oldTemplate.getName()) &&
        MessageDialog.openQuestion(getShell(),
        TextEditorTemplateMessages.TemplatePreferencePage_question_create_new_title,
        TextEditorTemplateMessages.TemplatePreferencePage_question_create_new_message))
      {
        data= new TemplatePersistenceData(newTemplate, true);
View Full Code Here

     * @since 3.1
     */
    protected void okPressed() {
      String name= fNameText == null ? fOriginalTemplate.getName() : fNameText.getText();
      boolean isAutoInsertable= fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection();
      fNewTemplate= new Template(name, fDescriptionText.getText(), getContextId(), fPatternEditor.getDocument().get(), isAutoInsertable);
      super.okPressed();
    }
View Full Code Here

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

      switch (columnIndex) {
        case 0:
          return template.getName();
        case 1:
          TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
          if (type != null)
            return type.getName();
          return template.getContextTypeId();
        case 2:
          return template.getDescription();
        case 3:
          return template.isAutoInsertable() ? TextEditorTemplateMessages.TemplatePreferencePage_on : ""//$NON-NLS-1$
        default:
          return ""; //$NON-NLS-1$
      }
    }
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.