I'm trying to add a template completion into a provider, but so far without success. I downloaded version 2.0.5 of auto-complete and rsyntaxtextarea.
I already saw this post: http://fifesoft.com/blog/?p=533.
In fact, this is the example that i'm trying to run to test the Template Completion.
Can anyone give me another example?
java code:
/* Constructor - OCLEditorPanel extends JPanel */
public OCLEditorPanel ()
{
RSyntaxTextArea textArea = new RSyntaxTextArea(5, 30);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
textArea.setAntiAliasingEnabled(true);
textArea.setCodeFoldingEnabled(false);
textArea.setForeground(Color.BLACK);
textArea.setBackground(new Color(255, 255, 255));
textArea.setCurrentLineHighlightColor(ColorPalette.getInstance().getColor(ThemeColor.GREEN_LIGHTEST));
setFont(textArea,new Font("Consolas", Font.PLAIN, 11));
Theme theme;
try {
theme = Theme.load(getClass().getResourceAsStream("/br/ufes/inf/nemo/move/ui/ocl/eclipse.xml"));
theme.apply(textArea);
} catch (IOException e) {
e.printStackTrace();
}
OCLTokenMaker tm = new OCLTokenMaker();
((RSyntaxDocument)textArea.getDocument()).setSyntaxStyle(tm);
DefaultCompletionProvider provider = new DefaultCompletionProvider();
// testing the Template Completion...
provider.addCompletion(new TemplateCompletion(provider, "for", "for-loop", "for (int ${i} = 0; ${i} < ${array}.length; ${i}++) {${cursor}"));
AutoCompletion ac = new AutoCompletion(provider);
ac.install(textArea);
ac.setAutoActivationEnabled(true);
ac.setShowDescWindow(true);
setLayout(new BorderLayout(0, 0));
RTextScrollPane scrollPane = new RTextScrollPane(textArea);
scrollPane.getGutter().setLineNumberColor(Color.GRAY);
scrollPane.getTextArea().setRows(5);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
setPreferredSize(new Dimension(400, 100));
add(scrollPane);
}
