Package org.eclipse.jface.text.templates

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


  /**
   * 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


    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

  private ContextTypeRegistry getTemplateContextRegistry() {
    return JSPUIPlugin.getDefault().getTemplateContextRegistry();
  }

  protected Template[] getTemplates(String contextTypeId) {
    Template templates[] = null;

    TemplateStore store = getTemplateStore();
    if (store != null)
      templates = store.getTemplates(contextTypeId);
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

    fTableViewer.setContentProvider(new TemplateContentProvider());

    fTableViewer.setSorter(new ViewerSorter() {
      public int compare(Viewer viewer, Object object1, Object object2) {
        if ((object1 instanceof Template) && (object2 instanceof Template)) {
          Template left = (Template) object1;
          Template right = (Template) object2;
          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

  void enableTemplates() {
    boolean enabled = fUseTemplateButton.getSelection();

    if (!enabled) {
      // save last selected template
      Template template = getSelectedTemplate();
      if (template != null)
        fLastSelectedTemplateName = template.getName();
      else
        fLastSelectedTemplateName = ""; //$NON-NLS-1$

      fTableViewer.setSelection(null);
    }
View Full Code Here

   * Get the currently selected template.
   *
   * @return
   */
  private Template getSelectedTemplate() {
    Template template = null;
    IStructuredSelection selection = (IStructuredSelection) fTableViewer.getSelection();

    if (selection.size() == 1) {
      template = (Template) selection.getFirstElement();
    }
View Full Code Here

   * @return String to insert or null if none is to be inserted
   */
  String getTemplateString() {
    String templateString = null;

    Template template = getSelectedTemplate();
    if (template != null) {
      TemplateContextType contextType = JSPUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsJSP.NEW);
      IDocument document = new Document();
      TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
      try {
View Full Code Here

    boolean setSelection = false;
    String templateName = JSPUIPlugin.getDefault().getPreferenceStore().getString(JSPUIPreferenceNames.NEW_FILE_TEMPLATE_NAME);
    if (templateName == null || templateName.length() == 0) {
      templateName = JSPUIPlugin.getDefault().getPreferenceStore().getString(JSPUIPreferenceNames.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 JSP File wizard.
   */
  void saveLastSavedPreferences() {
    String templateName = ""; //$NON-NLS-1$

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

    JSPUIPlugin.getDefault().getPreferenceStore().setValue(JSPUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
    JSPUIPlugin.getDefault().savePluginPreferences();
  }
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.