@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()]); }
@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 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 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; }
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; }
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); contexts.add(new String[] { type.getId(), type.getName() });
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); contexts.add(new String[] { type.getId(), type.getName() });
/** * 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); }
for (Iterator it = registry.contextTypes(); it.hasNext();)
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); fTableViewer.setSelection(new StructuredSelection(data)); } } }
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); if (type.getId().equals("javadoc")) //$NON-NLS-1$
for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= it.next(); if (type.getId().equals("javadoc")) //$NON-NLS-1$
private void add() { Iterator<TemplateContextType> it= fContextTypeRegistry.contextTypes(); if (it.hasNext()) { Template template= new Template("", "", 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); fTableViewer.setSelection(new StructuredSelection(data)); } } }
private void add() { Iterator<TemplateContextType> it= fContextTypeRegistry.contextTypes(); if (it.hasNext()) { Template template= new Template("", "", 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); fTableViewer.setSelection(new StructuredSelection(data)); } } }
for (Iterator it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= (TemplateContextType) it.next(); if (type.getId().equals("javadoc")) //$NON-NLS-1$
/** * Returns the context type id of the selected template. * * @return the context type id of the selected template or the first from the * registry if no templates are selected */ private String getContextTypeId() { IStructuredSelection selection = fTreeViewer.getStructuredSelection(); Object item; if (selection.size() == 0) return getContextTypeRegistry().contextTypes().next().getId(); if (selection.size() == 1) { item= selection.getFirstElement(); if (item instanceof TemplatePersistenceData) return ((TemplatePersistenceData) item).getTemplate().getContextTypeId(); return ((TemplateContextType) item).getId(); } Iterator<?> it= selection.iterator(); String contextId= null; while (it.hasNext()) { item= it.next(); if (contextId == null) contextId= getContextId(item); else if (!contextId.equals(getContextId(item))) return getContextTypeRegistry().contextTypes().next() .getId(); } return contextId; }
/** * Returns the context type id of the selected template. * * @return the context type id of the selected template or the first from the * registry if no templates are selected */ private String getContextTypeId() { IStructuredSelection selection= (IStructuredSelection) fTreeViewer.getSelection(); Object item; if (selection.size() == 0) return getContextTypeRegistry().contextTypes().next().getId(); if (selection.size() == 1) { item= selection.getFirstElement(); if (item instanceof TemplatePersistenceData) return ((TemplatePersistenceData) item).getTemplate().getContextTypeId(); return ((TemplateContextType) item).getId(); } Iterator<?> it= selection.iterator(); String contextId= null; while (it.hasNext()) { item= it.next(); if (contextId == null) contextId= getContextId(item); else if (!contextId.equals(getContextId(item))) return getContextTypeRegistry().contextTypes().next() .getId(); } return contextId; }