| 1 | /** |
| 2 | * |
| 3 | */ |
| 4 | package de.uka.ipd.sdq.pcm.dialogs.stoex; |
| 5 | |
| 6 | import java.util.ArrayList; |
| 7 | import java.util.List; |
| 8 | |
| 9 | import org.eclipse.jface.text.IRegion; |
| 10 | import org.eclipse.jface.text.ITextViewer; |
| 11 | import org.eclipse.jface.text.templates.Template; |
| 12 | import org.eclipse.jface.text.templates.TemplateCompletionProcessor; |
| 13 | import org.eclipse.jface.text.templates.TemplateContextType; |
| 14 | import org.eclipse.swt.graphics.Image; |
| 15 | |
| 16 | /** |
| 17 | * @author Steffen Becker |
| 18 | * |
| 19 | */ |
| 20 | public class StoExTemplateCompletionProcessor extends |
| 21 | TemplateCompletionProcessor { |
| 22 | |
| 23 | public static final String STO_EX_CONTEXT_TYPE = "StoExContextType"; |
| 24 | |
| 25 | /** |
| 26 | * |
| 27 | */ |
| 28 | public StoExTemplateCompletionProcessor() { |
| 29 | // TODO Auto-generated constructor stub |
| 30 | } |
| 31 | |
| 32 | /* (non-Javadoc) |
| 33 | * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) |
| 34 | */ |
| 35 | @Override |
| 36 | protected TemplateContextType getContextType(ITextViewer viewer, |
| 37 | IRegion region) { |
| 38 | return new TemplateContextType(STO_EX_CONTEXT_TYPE); |
| 39 | } |
| 40 | |
| 41 | /* (non-Javadoc) |
| 42 | * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) |
| 43 | */ |
| 44 | @Override |
| 45 | protected Image getImage(Template template) { |
| 46 | return null; |
| 47 | } |
| 48 | |
| 49 | /* (non-Javadoc) |
| 50 | * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) |
| 51 | */ |
| 52 | @Override |
| 53 | protected Template[] getTemplates(String contextTypeId) { |
| 54 | List<Template> templates = new ArrayList<Template>(); |
| 55 | |
| 56 | // Template with units: |
| 57 | // templates.add(new Template("DoublePDF", |
| 58 | // "Creates a double random variable (BoxedPDF)", STO_EX_CONTEXT_TYPE, |
| 59 | // "DoublePDF(unit=\"${unit}\")[(${x};${p})(${y};${q})(${z};${r})]", false)); |
| 60 | // templates.add(new Template("IntPMF", |
| 61 | // "Creates an integer random variable", STO_EX_CONTEXT_TYPE, |
| 62 | // "IntPMF(unit=\"${unit}\")[(${x};${p})(${y};${q})(${z};${r})]", false)); |
| 63 | // templates.add(new Template("DoublePMF", |
| 64 | // "Creates a double random variable", STO_EX_CONTEXT_TYPE, |
| 65 | // "DoublePMF(unit=\"${unit}\")[(${x};${p})(${y};${q})(${z};${r})]", false)); |
| 66 | // templates.add(new Template("BoolPMF", |
| 67 | // "Creates a boolean random variable", STO_EX_CONTEXT_TYPE, |
| 68 | // "BoolPMF(unit=\"bool\")[(true;${p})(false;${q})]", false)); |
| 69 | // templates.add(new Template("EnumPMF", |
| 70 | // "Creates a enum random variable", STO_EX_CONTEXT_TYPE, |
| 71 | // "EnumPMF(unit=\"${unit}\")[(${x};${p})]", false)); |
| 72 | |
| 73 | templates.add(new Template("DoublePDF", |
| 74 | "Creates a double random variable (BoxedPDF)", STO_EX_CONTEXT_TYPE, |
| 75 | "DoublePDF[(${x};${p})(${y};${q})(${z};${r})]", false)); |
| 76 | templates.add(new Template("IntPMF", |
| 77 | "Creates an integer random variable", STO_EX_CONTEXT_TYPE, |
| 78 | "IntPMF[(${x};${p})(${y};${q})(${z};${r})]", false)); |
| 79 | templates.add(new Template("DoublePMF", |
| 80 | "Creates a double random variable", STO_EX_CONTEXT_TYPE, |
| 81 | "DoublePMF[(${x};${p})(${y};${q})(${z};${r})]", false)); |
| 82 | templates.add(new Template("BoolPMF", |
| 83 | "Creates a boolean random variable", STO_EX_CONTEXT_TYPE, |
| 84 | "BoolPMF[(true;${p})(false;${q})]", false)); |
| 85 | templates.add(new Template("EnumPMF", |
| 86 | "Creates a enum random variable", STO_EX_CONTEXT_TYPE, |
| 87 | "EnumPMF[(${x};${p})]", false)); |
| 88 | |
| 89 | return templates.toArray(new Template[templates.size()]); |
| 90 | } |
| 91 | } |