Search in sources :

Example 1 with SQLWordPartDetector

use of org.jkiss.dbeaver.ui.editors.sql.syntax.SQLWordPartDetector in project dbeaver by serge-rider.

the class ResultSetFilterPanel method getProposals.

@Override
public IContentProposal[] getProposals(String contents, int position) {
    SQLSyntaxManager syntaxManager = new SQLSyntaxManager();
    if (viewer.getDataContainer() != null) {
        syntaxManager.init(viewer.getDataContainer().getDataSource());
    }
    SQLWordPartDetector wordDetector = new SQLWordPartDetector(new Document(contents), syntaxManager, position);
    final String word = wordDetector.getFullWord().toLowerCase(Locale.ENGLISH);
    List<IContentProposal> proposals = new ArrayList<>();
    for (DBDAttributeBinding attribute : viewer.getModel().getAttributes()) {
        final String name = attribute.getName();
        if (CommonUtils.isEmpty(word) || name.toLowerCase(Locale.ENGLISH).startsWith(word)) {
            final String content = name.substring(word.length()) + " ";
            proposals.add(new ContentProposal(content, attribute.getName(), SQLContextInformer.makeObjectDescription(null, attribute.getAttribute(), false), content.length()));
        }
    }
    return proposals.toArray(new IContentProposal[proposals.size()]);
}
Also used : ContentProposal(org.eclipse.jface.fieldassist.ContentProposal) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) SQLWordPartDetector(org.jkiss.dbeaver.ui.editors.sql.syntax.SQLWordPartDetector) SQLSyntaxManager(org.jkiss.dbeaver.model.sql.SQLSyntaxManager) ArrayList(java.util.ArrayList) Document(org.eclipse.jface.text.Document) DBDAttributeBinding(org.jkiss.dbeaver.model.data.DBDAttributeBinding)

Aggregations

ArrayList (java.util.ArrayList)1 ContentProposal (org.eclipse.jface.fieldassist.ContentProposal)1 IContentProposal (org.eclipse.jface.fieldassist.IContentProposal)1 Document (org.eclipse.jface.text.Document)1 DBDAttributeBinding (org.jkiss.dbeaver.model.data.DBDAttributeBinding)1 SQLSyntaxManager (org.jkiss.dbeaver.model.sql.SQLSyntaxManager)1 SQLWordPartDetector (org.jkiss.dbeaver.ui.editors.sql.syntax.SQLWordPartDetector)1