/** * Returns <code>true</code> if a context type id specifies a valid context type * or if no context type registry is present. * * @param contextTypeId the context type id to look for * @return <code>true</code> if the context type specified by the id * is present in the context type registry, or if no registry is * specified */ private boolean contextExists(String contextTypeId) { return contextTypeId != null && (fRegistry == null || fRegistry.getContextType(contextTypeId) != null); }
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); contexts.add(new String[] { type.getId(), type.getName() }); TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); fTemplateProcessor.setContextType(type);
@Override protected final org.eclipse.jface.text.templates.ContextTypeRegistry getRegistry() { ContextTypeRegistry registry= super.getRegistry(); if (registry == null) { return null; } org.eclipse.jface.text.templates.ContextTypeRegistry res= new org.eclipse.jface.text.templates.ContextTypeRegistry(); registry.contextTypes().forEachRemaining(t -> res.addContextType(t)); return res; }
public TemplateCompletionProposalComputer() { TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(JavaContextType.NAME); if (contextType == null) { contextType= new JavaContextType(); JavaPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType); } if (contextType != null) fJavaTemplateEngine= new TemplateEngine(contextType); else fJavaTemplateEngine= null; contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType("javadoc"); //$NON-NLS-1$ if (contextType == null) { contextType= new JavaDocContextType(); JavaPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType); } if (contextType != null) fJavadocTemplateEngine= new TemplateEngine(contextType); else fJavadocTemplateEngine= null; }
@Override public Object[] getElements(Object inputElement) { List<TemplateContextType> contextTypes= new ArrayList<>(); for (Iterator<TemplateContextType> iterator= getContextTypeRegistry().contextTypes(); iterator.hasNext();) { TemplateContextType contextType= iterator.next(); if (!fLinkWithEditorAction.isChecked() || isActiveContext(contextType)) contextTypes.add(contextType); } return contextTypes.toArray(new TemplateContextType[contextTypes.size()]); }
public static void registerContextTypes(ContextTypeRegistry registry) { registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CATCHBLOCK_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NEWTYPE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CLASSBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.INTERFACEBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.ENUMBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.ANNOTATIONBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FILECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.TYPECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FIELDCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.OVERRIDECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.DELEGATECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERCOMMENT_CONTEXTTYPE)); }
@Override public Object[] getElements(Object inputElement) { List<TemplateContextType> contextTypes= new ArrayList<>(); for (Iterator<TemplateContextType> iterator= getContextTypeRegistry().contextTypes(); iterator.hasNext();) { TemplateContextType contextType= iterator.next(); if (!fLinkWithEditorAction.isChecked() || isActiveContext(contextType)) contextTypes.add(contextType); } return contextTypes.toArray(new TemplateContextType[contextTypes.size()]); }
public static void registerContextTypes(ContextTypeRegistry registry) { registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CATCHBLOCK_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.NEWTYPE_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CLASSBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.INTERFACEBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.ENUMBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.ANNOTATIONBODY_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FILECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.TYPECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.FIELDCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.METHODCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.CONSTRUCTORCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.OVERRIDECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.DELEGATECOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.GETTERCOMMENT_CONTEXTTYPE)); registry.addContextType(new CodeTemplateContextType(CodeTemplateContextType.SETTERCOMMENT_CONTEXTTYPE)); }
protected void addContextType(String id) { TemplateContextType contextType = registry.getContextType(id); if (contextType != null) result.add(contextType); } }
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); contexts.add(new String[] { type.getId(), type.getName() }); TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); fTemplateProcessor.setContextType(type);
private int computeMinimumContextColumnWidth(GC gc) { int width= gc.stringExtent(TemplatesMessages.TemplatePreferencePage_column_context).x; Iterator<TemplateContextType> iter= getContextTypeRegistry().contextTypes(); while (iter.hasNext()) { TemplateContextType contextType= iter.next(); width= Math.max(width, gc.stringExtent(contextType.getName()).x); } return width; }
public ContextTypeRegistry getContextTypeRegistry() { if (registry == null) { if (WikiTextUiPlugin.getDefault() != null) { ContributionContextTypeRegistry contributionRegistry = new ContributionContextTypeRegistry(); contributionRegistry.addContextType(SourceTemplateContextType.ID); registry = contributionRegistry; } else { ContextTypeRegistry contextTypeRegistry = new ContextTypeRegistry(); contextTypeRegistry.addContextType(new SourceTemplateContextType()); registry = contextTypeRegistry; } } return registry; }
private static TemplateEngine createTemplateEngine(ContextTypeRegistry templateContextRegistry, String contextTypeId) { TemplateContextType contextType= templateContextRegistry.getContextType(contextTypeId); Assert.isNotNull(contextType); return new TemplateEngine(contextType); }
/** * Creates a new dialog. * * @param parent the shell parent of the dialog * @param template the template to edit * @param edit whether this is a new template or an existing being edited * @param isNameModifiable whether the name of the template may be modified * @param registry the context type registry to use */ public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) { super(parent); setShellStyle(getShellStyle() | SWT.MAX | SWT.RESIZE); String title= edit ? TextEditorTemplateMessages.EditTemplateDialog_title_edit : TextEditorTemplateMessages.EditTemplateDialog_title_new; setTitle(title); 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); }
public EditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry, TemplatesLanguageConfiguration configuration, IEditedResourceProvider resourceProvider, String languageName) { super(parent); this.configuration = configuration; this.resourceProvider = resourceProvider; this.languageName = languageName; String title= edit ? TemplateDialogMessages.EditTemplateDialog_title_edit : TemplateDialogMessages.EditTemplateDialog_title_new; setTitle(title); this.fTemplate= template; fIsNameModifiable= isNameModifiable; List<String[]> contexts= Lists.newArrayList(); for (Iterator<TemplateContextType> it= Iterators.filter(registry.contextTypes(), TemplateContextType.class); it.hasNext();) { TemplateContextType type= it.next(); contexts.add(new String[] { type.getId(), type.getName() }); } fContextTypes= contexts.toArray(new String[contexts.size()][]); fContextTypeRegistry= registry; }
private static TemplateEngine createTemplateEngine(ContextTypeRegistry templateContextRegistry, String contextTypeId) { TemplateContextType contextType= templateContextRegistry.getContextType(contextTypeId); Assert.isNotNull(contextType); return new TemplateEngine(contextType); }
for (Iterator it = registry.contextTypes(); it.hasNext();) TemplateContextType type = _fContextTypeRegistry.getContextType(template.getContextTypeId()); _fTemplateProcessor.setContextType(type);
private int computeMinimumContextColumnWidth(GC gc) { int width= gc.stringExtent(TemplatesMessages.TemplatePreferencePage_column_context).x; Iterator<TemplateContextType> iter= getContextTypeRegistry().contextTypes(); while (iter.hasNext()) { TemplateContextType contextType= iter.next(); width= Math.max(width, gc.stringExtent(contextType.getName()).x); } return width; }
protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { TemplateContextType type = null; ContextTypeRegistry registry = getTemplateContextRegistry(); if (registry != null) { type = registry.getContextType(fContextTypeId); } return type; }
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); if (type.getId().equals("javadoc")) //$NON-NLS-1$ TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); fTemplateProcessor.setContextType(type);