@Override public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { // bug 114360 - don't make selection templates prefix-completable if (isSelectionTemplate()) return ""; //$NON-NLS-1$ return fTemplate.getName(); }
@Override public Object getParent(TreeListDialogField<String> 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; } return null; }
public CharSequence getPrefixCompletionText(IDocument document, int completionOffset) { // bug 114360 - don't make selection templates prefix-completable if (isSelectionTemplate()) return ""; //$NON-NLS-1$ return fTemplate.getName(); }
public String getColumnText(Object element, int columnIndex) { Template template = (Template) element; switch (columnIndex) { case 0 : return template.getName(); case 1 : return template.getDescription(); default : return ""; //$NON-NLS-1$ } } }
protected TemplatePersistenceData[] getTemplateOfCategory(boolean isComment) { ArrayList<TemplatePersistenceData> 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 res.toArray(new TemplatePersistenceData[res.size()]); }
protected TemplatePersistenceData[] getTemplateOfCategory(boolean isComment) { ArrayList<TemplatePersistenceData> 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 res.toArray(new TemplatePersistenceData[res.size()]); }
public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof Template) && (object2 instanceof Template)) { Template left = (Template) object1; Template right = (Template) object2; int result = left.getName().compareToIgnoreCase(right.getName()); if (result != 0) { return result; } return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); }
private int getRelevance(Template template, int lineOffset, String prefix) { boolean blockTemplate = templates == null ? false : templates.isBlock(template); if (blockTemplate) { if (template.getName().startsWith(prefix)) { return lineOffset == 0 ? 95 : 75; } return lineOffset == 0 ? 85 : 0; } return super.getRelevance(template, prefix); }
protected String getPrefix() { String contextName = getContextName(); String name = fTemplate.getName(); if (fNameText != null && !fNameText.isDisposed()) { name = fNameText.getText(); } String prefix = "templates for " + languageName + " '" + name + "'" + " for " + contextName + " >>"; return prefix; }
@Override public StyledString getStyledDisplayString() { if (fDisplayString == null) { String[] arguments= new String[] { fTemplate.getName(), fTemplate.getDescription() }; String decorated= Messages.format(TemplateContentAssistMessages.TemplateProposal_displayString, arguments); StyledString string= new StyledString(fTemplate.getName(), StyledString.COUNTER_STYLER); fDisplayString= StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.QUALIFIER_STYLER, string); } return fDisplayString; }
@Override public String getDisplayString() { if (fDisplayString == null) { String[] arguments= new String[] { fTemplate.getName(), fTemplate.getDescription() }; fDisplayString= JFaceTextTemplateMessages.getFormattedString("TemplateProposal.displayString", arguments); //$NON-NLS-1$ } return fDisplayString; }
public boolean canEvaluate(Template template) { if (fForceEvaluation) return true; String key= getKey(); return template.matches(key, getContextType().getId()) && key.length() != 0 && template.getName().toLowerCase().startsWith(key.toLowerCase()); }
public String getDisplayString() { if (_displayString == null) { String[] arguments = new String[] { _template.getName(), _template.getDescription() }; _displayString = Messages.getFormattedString("TemplateProposal.displayString", arguments); //$NON-NLS-1$ } return _displayString; }
public boolean canEvaluate(Template template) { String key= getKey(); if (fForceEvaluation) return true; return template.matches(key, getContextType().getId()) && (key.length() != 0) && template.getName().toLowerCase().startsWith(key.toLowerCase()); }
@Override public String getDisplayString() { if (fDisplayString == null) { String[] arguments= new String[] { fTemplate.getName(), fTemplate.getDescription() }; fDisplayString= JFaceTextTemplateMessages.getFormattedString("TemplateProposal.displayString", arguments); //$NON-NLS-1$ } return fDisplayString; }
protected void okPressed() { String name= fNameText == null ? fOriginalTemplate.getName() : fNameText.getText(); boolean isAutoInsertable= fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection(); fNewTemplate= new Template(name, fDescriptionText.getText(), getContextId(), fPatternEditor.getDocument().get(), isAutoInsertable); super.okPressed(); }
@Override protected void okPressed() { String name= fNameText == null ? fOriginalTemplate.getName() : fNameText.getText(); boolean isAutoInsertable= fAutoInsertCheckbox != null && fAutoInsertCheckbox.getSelection(); fNewTemplate= new Template(name, fDescriptionText.getText(), getContextId(), fPatternEditor.getDocument().get(), isAutoInsertable); super.okPressed(); }
private String getTemplateColumnText(TemplatePersistenceData data, int columnIndex) { switch (columnIndex) { case 0: return data.getTemplate().getName(); case 1: return data.getTemplate().getDescription(); default: return ""; //$NON-NLS-1$ } }
/** * Creates a copy of a template. * * @param template the template to copy */ public Template(Template template) { this(template.getName(), template.getDescription(), template.getContextTypeId(), template.getPattern(), template.isAutoInsertable()); }
public static void setCodeTemplate(String templateId, String pattern, IJavaProject project) { TemplateStore codeTemplateStore= JavaPlugin.getDefault().getCodeTemplateStore(); TemplatePersistenceData data= codeTemplateStore.getTemplateData(templateId); Template orig= data.getTemplate(); Template copy= new Template(orig.getName(), orig.getDescription(), orig.getContextTypeId(), pattern, true); data.setTemplate(copy); }