private String getContextColumnText(TemplateContextType contextType, int columnIndex) { switch (columnIndex) { case 0: return contextType.getName(); default: return ""; //$NON-NLS-1$ } } }
private String getContextColumnText(TemplateContextType contextType, int columnIndex) { switch (columnIndex) { case 0: return contextType.getName(); default: return ""; //$NON-NLS-1$ } } }
protected String getContextTypeForGrammar(TemplateContextType contextType) { String result = contextType.getName(); if (result.startsWith("Keyword ")) result = result.substring("Keyword ".length()); return result; }
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$ } }
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$ } }
public int compareTo(TemplateContextType templateContextType) { int result = getName().compareTo(templateContextType.getName()); if (result == 0) { return getId().compareTo(templateContextType.getId()); } return result; }
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 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; }
protected String getContextName() { String result; if (fContextCombo != null && !fContextCombo.isDisposed()) { result = fContextCombo.getText(); } else { String contextId = fTemplate.getContextTypeId(); result = fContextTypeRegistry.getContextType(contextId).getName(); } if (result.startsWith("Keyword ")) result = result.substring("Keyword ".length()); return result; }
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); }
contexts.add(new String[] type.getId(), type.getName()
@Override public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof TemplatePersistenceData) && (object2 instanceof TemplatePersistenceData)) { Template left= ((TemplatePersistenceData) object1).getTemplate(); Template right= ((TemplatePersistenceData) object2).getTemplate(); int result= Collator.getInstance().compare(left.getName(), right.getName()); if (result != 0) return result; return Collator.getInstance() .compare(left.getDescription(), right.getDescription()); } if ((object1 instanceof TemplateContextType) && (object2 instanceof TemplateContextType)) { return Collator.getInstance().compare(((TemplateContextType) object1).getName(), ((TemplateContextType) object1).getName()); } return super.compare(viewer, object1, object2); }
@Override public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof TemplatePersistenceData) && (object2 instanceof TemplatePersistenceData)) { Template left= ((TemplatePersistenceData) object1).getTemplate(); Template right= ((TemplatePersistenceData) object2).getTemplate(); int result= Collator.getInstance().compare(left.getName(), right.getName()); if (result != 0) return result; return Collator.getInstance() .compare(left.getDescription(), right.getDescription()); } if ((object1 instanceof TemplateContextType) && (object2 instanceof TemplateContextType)) { return Collator.getInstance().compare(((TemplateContextType) object1).getName(), ((TemplateContextType) object1).getName()); } return super.compare(viewer, object1, object2); }
@Override public String getColumnText(Object element, int columnIndex) { TemplatePersistenceData data = (TemplatePersistenceData) element; Template template= data.getTemplate(); 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() ? TemplatesMessages.TemplatePreferencePage_on : ""; //$NON-NLS-1$ default: return ""; //$NON-NLS-1$ } } }
public String getColumnText(Object element, int columnIndex) { TemplatePersistenceData data = (TemplatePersistenceData) element; Template template= data.getTemplate(); 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$ default: return ""; //$NON-NLS-1$ } } }
@Override public String getColumnText(Object element, int columnIndex) { TemplatePersistenceData data = (TemplatePersistenceData) element; Template template= data.getTemplate(); 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() ? TemplatesMessages.TemplatePreferencePage_on : ""; //$NON-NLS-1$ default: return ""; //$NON-NLS-1$ } } }