Package org.eclipse.jface.text.templates.persistence

Examples of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData


  /**
   * Edits the selected template.
   */
  private void editTemplate() {
    TemplatePersistenceData selectedTemplate= getSelectedTemplates()[0];
    Template oldTemplate= selectedTemplate.getTemplate();
    Template newTemplate= editTemplate(new Template(oldTemplate), true, true);
    if (newTemplate != null) {
      if (!newTemplate.getName().equals(oldTemplate.getName())
          && MessageDialog.openQuestion(getShell(),
              TemplatesMessages.TemplatesPage_question_create_new_title,
              TemplatesMessages.TemplatesPage_question_create_new_message)) {
        TemplatePersistenceData templateData= new TemplatePersistenceData(newTemplate,
            true);
        getTemplateStore().add(templateData);
        refresh();
        fTreeViewer.setSelection(new StructuredSelection(templateData), true);
      } else {
View Full Code Here


   */
  private void copyTemplates(TemplatePersistenceData[] templates, String contextId) {
    TemplatePersistenceData[] newTemplates= new TemplatePersistenceData[templates.length];
    for (int i= 0; i < templates.length; i++) {
      Template t= templates[i].getTemplate();
      newTemplates[i]= new TemplatePersistenceData(new Template(t.getName(), t
          .getDescription(), contextId, t.getPattern(), t.isAutoInsertable()), true);
      getTemplateStore().add(newTemplates[i]);
    }
    saveTemplateStore();
    refresh();
View Full Code Here

    /*
     * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
     */
    public Object getParent(Object element) {
      if (element instanceof TemplatePersistenceData) {
        TemplatePersistenceData templateData= (TemplatePersistenceData) element;
        return getContextTypeRegistry().getContextType(
            templateData.getTemplate().getContextTypeId());
      }
      return null;
    }
View Full Code Here

    protected void afterEditorCreated(IEditorPart openEditor) {
        if (!(openEditor instanceof PyEdit)) {
            return; //only works for PyEdit...
        }

        TemplatePersistenceData selectedTemplate = filePage.getSelectedTemplate();
        if (selectedTemplate == null) {
            return; //no template selected, nothing to apply!
        }

        Template template = selectedTemplate.getTemplate();

        PyEdit pyEdit = (PyEdit) openEditor;
        Region region = new Region(0, 0);
        PyDocumentTemplateContext context = PyTemplateCompletionProcessor.createContext(new PyContextType(),
                pyEdit.getPySourceViewer(), region);
View Full Code Here

  protected TemplatePersistenceData[] getTemplateOfCategory(boolean isComment) {
    ArrayList res = new ArrayList();
    TemplatePersistenceData[] templates = fTemplateStore.getTemplateData();
    for (int i = 0; i < templates.length; i++) {
      TemplatePersistenceData curr = templates[i];
      if (isComment == curr.getTemplate().getName().endsWith(
          CodeTemplateContextType.COMMENT_SUFFIX)) {
        res.add(curr);
      }
    }
    return (TemplatePersistenceData[]) res
View Full Code Here

        || fPatternViewer.getTextWidget().isDisposed()) {
      return;
    }
    if (selection.size() == 1
        && selection.get(0) instanceof TemplatePersistenceData) {
      TemplatePersistenceData data = (TemplatePersistenceData) selection
          .get(0);
      Template template = data.getTemplate();
      TemplateContextType type = PHPUiPlugin.getDefault()
          .getCodeTemplateContextRegistry().getContextType(
              template.getContextTypeId());
      fTemplateProcessor.setContextType(type);
      fPatternViewer.getDocument().set(template.getPattern());
View Full Code Here

      return NO_CHILDREN;
    }

    public Object getParent(TreeListDialogField field, Object element) {
      if (element instanceof TemplatePersistenceData) {
        TemplatePersistenceData data = (TemplatePersistenceData) element;
        if (data.getTemplate().getName().endsWith(
            CodeTemplateContextType.COMMENT_SUFFIX)) {
          return COMMENT_NODE;
        }
        return CODE_NODE;
      }
View Full Code Here

        return 1;
      } else if (element == CODE_NODE) {
        return 2;
      }

      TemplatePersistenceData data = (TemplatePersistenceData) element;
      String id = data.getId();

      if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
        return 101;
      } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
        return 102;
View Full Code Here

     */
    public String getText(Object element) {
      if (element == COMMENT_NODE || element == CODE_NODE) {
        return (String) element;
      }
      TemplatePersistenceData data = (TemplatePersistenceData) element;
      String id = data.getId();
      if (CodeTemplateContextType.CATCHBLOCK_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_catchblock_label;
      } else if (CodeTemplateContextType.METHODSTUB_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_methodstub_label;
      } else if (CodeTemplateContextType.CONSTRUCTORSTUB_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_constructorstub_label;
      } else if (CodeTemplateContextType.GETTERSTUB_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_getterstub_label;
      } else if (CodeTemplateContextType.SETTERSTUB_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_setterstub_label;
      } else if (CodeTemplateContextType.NEWTYPE_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_newtype_label;
      } else if (CodeTemplateContextType.CLASSBODY_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_classbody_label;
      } else if (CodeTemplateContextType.INTERFACEBODY_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_interfacebody_label;
      } else if (CodeTemplateContextType.ENUMBODY_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_enumbody_label;
      } else if (CodeTemplateContextType.ANNOTATIONBODY_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_annotationbody_label;
      } else if (CodeTemplateContextType.FILECOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_filecomment_label;
      } else if (CodeTemplateContextType.TYPECOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_typecomment_label;
      } else if (CodeTemplateContextType.FIELDCOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_fieldcomment_label;
      } else if (CodeTemplateContextType.METHODCOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_methodcomment_label;
      } else if (CodeTemplateContextType.OVERRIDECOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_overridecomment_label;
      } else if (CodeTemplateContextType.DELEGATECOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_delegatecomment_label;
      } else if (CodeTemplateContextType.CONSTRUCTORCOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_constructorcomment_label;
      } else if (CodeTemplateContextType.GETTERCOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_gettercomment_label;
      } else if (CodeTemplateContextType.SETTERCOMMENT_ID.equals(id)) {
        return PreferencesMessages.CodeTemplateBlock_settercomment_label;
      }
      return data.getTemplate().getDescription();
    }
View Full Code Here

        datas.add(data[i].getId());
      }

      data = fInstanceStore.getTemplateData(false);
      for (int i = 0; i < data.length; i++) {
        TemplatePersistenceData orig = data[i];
        if (!datas.contains(orig.getId())) {
          TemplatePersistenceData copy = new TemplatePersistenceData(
              new Template(orig.getTemplate()), orig.isEnabled(),
              orig.getId());
          fProjectStore.add(copy);
          copy.setDeleted(true);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.templates.persistence.TemplatePersistenceData

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.