Hi,
For a couple of days now, I'm trying to create an Eclipse view with an area where I can edit sql. I want this area to have syntax highlighting, code completion, auto format, line numbers etc.
I found out that the SqlStatementArea of the Eclipse Data Tools project has this ability. I've used this in my project and the syntax highlighting works out of the box but when I hit CTRL+SPACE nothing happens.
This is my code:
SQLSourceEditingEnvironment.connect();
service = new CustomSQLSourceViewerService();
sta = new SQLStatementArea(this, SWT.BORDER, service, true);
sta.setEditable(true);
sta.setEnabled(true);
CustomSQLSourceViewerConfiguration sqlSourceViewerConfiguration = new CustomSQLSourceViewerConfiguration();
sqlSourceViewerConfiguration.setIsContentAssistActive(true);
sta.configureViewer(sqlSourceViewerConfiguration);
sta.setLayoutData(new GridData(GridData.FILL_BOTH));
document = new Document();
document.set("select * from test");
sta.getViewer().setDocument(document);
Allso I made a class which extends SQLSourceViewerConfiguration so I could override getContentFormatter (I want all keywords to be uppercase). This is the code for that:
@Override
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
ContentFormatter formatter = new ContentFormatter();
formatter.setFormattingStrategy(new SQLWordStrategy(new DefaultSQLSyntax()),
IDocument.DEFAULT_CONTENT_TYPE);
return formatter;
}
But there is no formatting applied.. Hope someone can help? Thanks in advance.
[Updated on: Fri, 07 September 2012 13:26]
Report message to a moderator