Examples of TemplateContextType


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

    @Override
    protected Template[] getTemplates(final String contextTypeId) {
        final Template[] templates = ErlideUIPlugin.getDefault().getTemplateStore()
                .getTemplates();
        final TemplateContextType type = ErlideUIPlugin.getDefault()
                .getContextTypeRegistry().getContextType(contextTypeId);
        if (type instanceof ErlangTemplateContextType) {
            final List<Template> result = new ArrayList<Template>(templates.length);
            final ErlangTemplateContext etc = new ErlangTemplateContext(type, fDocument,
                    offset, length);
View Full Code Here

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

        return p;
    }

    @Override
    protected TemplateContext createContext(final ITextViewer viewer, final IRegion region) {
        final TemplateContextType contextType = getContextType(viewer, region);
        if (contextType instanceof ErlangTemplateContextType) {
            final IDocument document = viewer.getDocument();
            return new ErlangTemplateContext(contextType, document, region.getOffset(),
                    region.getLength());
        }
View Full Code Here

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

    /**
     * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
     */
    protected TemplateContextType getContextType( ITextViewer viewer, IRegion region )
    {
        TemplateContextType contextType = BrowserCommonActivator.getDefault().getFilterTemplateContextTypeRegistry()
            .getContextType( BrowserCommonConstants.FILTER_TEMPLATE_ID );
        return contextType;
    }
View Full Code Here

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

  public void addContextType(String id) {
    Assert.isNotNull(id);
    if (getContextType(id) != null)
      return;

    TemplateContextType type= createContextType(id);
    if (type != null)
      addContextType(type);

  }
View Full Code Here

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

   */
  public static TemplateContextType createContextType(String id) {
    Assert.isNotNull(id);

    IConfigurationElement[] extensions= getTemplateExtensions();
    TemplateContextType type;
    try {
      type= createContextType(extensions, id);
      if (type != null) {
        TemplateVariableResolver[] resolvers= createResolvers(extensions, id);
        for (int i= 0; i < resolvers.length; i++)
          type.addResolver(resolvers[i]);
      }
    } catch (CoreException e) {
      EditorsPlugin.log(e);
      type= null;
    }
View Full Code Here

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

  }

  private static TemplateContextType createContextType(IConfigurationElement element) throws CoreException {
    String id= element.getAttribute(ID);
    try {
      TemplateContextType contextType= (TemplateContextType) element.createExecutableExtension(CLASS);
      String name= element.getAttribute(NAME);
      if (name == null)
        name= id;

      if (contextType.getId() == null)
        contextType.setId(id);
      if (contextType.getName() == null)
        contextType.setName(name);

      return contextType;
    } catch (ClassCastException e) {
      throw new CoreException(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, "extension does not implement " + TemplateContextType.class.getName(), e)); //$NON-NLS-1$
    }
View Full Code Here

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

      fOriginalTemplate= template;
      fIsNameModifiable= isNameModifiable;

      List contexts= new ArrayList();
      for (Iterator it= registry.contextTypes(); it.hasNext();) {
        TemplateContextType type= (TemplateContextType) it.next();
        contexts.add(new String[] { type.getId(), type.getName() });
      }
      fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]);

      fValidationStatus= new StatusInfo();

      fContextTypeRegistry= registry;

      TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId());
      fTemplateProcessor.setContextType(type);
    }
View Full Code Here

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

    }

    private void doSourceChanged(IDocument document) {
      String text= document.get();
      fValidationStatus.setOK();
      TemplateContextType contextType= fContextTypeRegistry.getContextType(getContextId());
      if (contextType != null) {
        try {
          contextType.validate(text);
        } catch (TemplateException e) {
          fValidationStatus.setError(e.getLocalizedMessage());
        }
      }
View Full Code Here

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

      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$
View Full Code Here

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

  String getTemplateString() {
    String templateString = null;

    Template template = getSelectedTemplate();
    if (template != null) {
      TemplateContextType contextType = JSPUIPlugin.getDefault().getTemplateContextRegistry().getContextType(TemplateContextTypeIdsJSP.NEW_TAG);
      IDocument document = new Document();
      TemplateContext context = new DocumentTemplateContext(contextType, document, 0, 0);
      try {
        TemplateBuffer buffer = context.evaluate(template);
        templateString = buffer.getString();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.