use of org.jkiss.dbeaver.model.runtime.SystemJob in project dbeaver by serge-rider.
the class ResultSetFilterPanel method getProposals.
@Override
public IContentProposal[] getProposals(String contents, int position) {
if (!viewer.getPreferenceStore().getBoolean(ResultSetPreferences.RESULT_SET_FILTER_AUTO_COMPLETE_PROPOSIAL)) {
return null;
}
SQLSyntaxManager syntaxManager = new SQLSyntaxManager();
DBPDataSource dataSource = viewer.getDataSource();
if (dataSource != null) {
syntaxManager.init(dataSource);
}
SQLWordPartDetector wordDetector = new SQLWordPartDetector(new Document(contents), syntaxManager, position);
String word = wordDetector.getFullWord();
final List<IContentProposal> proposals = new ArrayList<>();
if (CommonUtils.isEmptyTrimmed(word))
word = contents;
word = word.toLowerCase(Locale.ENGLISH);
String attrName = word;
final DBRRunnableWithProgress reader = monitor -> {
DBDAttributeBinding[] attributes = viewer.getModel().getAttributes();
for (DBDAttributeBinding attribute : attributes) {
if (attribute.isCustom()) {
continue;
}
final String name = DBUtils.getUnQuotedIdentifier(attribute.getDataSource(), attribute.getName());
if (CommonUtils.isEmpty(attrName) || name.toLowerCase(Locale.ENGLISH).startsWith(attrName)) {
final String content = DBUtils.getQuotedIdentifier(attribute) + " ";
proposals.add(new ContentProposalExt(content, attribute.getName(), DBInfoUtils.makeObjectDescription(monitor, attribute.getAttribute(), false), content.length(), DBValueFormatting.getObjectImage(attribute)));
}
}
};
SystemJob searchJob = new SystemJob("Extract attribute proposals", reader);
searchJob.schedule();
UIUtils.waitJobCompletion(searchJob);
String[] filterKeywords = { SQLConstants.KEYWORD_AND, SQLConstants.KEYWORD_OR, SQLConstants.KEYWORD_IS, SQLConstants.KEYWORD_NOT, SQLConstants.KEYWORD_NULL };
for (String kw : filterKeywords) {
if (attrName.isEmpty() || kw.startsWith(attrName.toUpperCase())) {
if (dataSource != null) {
kw = dataSource.getSQLDialect().storesUnquotedCase().transform(kw);
}
proposals.add(new ContentProposal(kw + " ", kw + ": SQL expression keyword"));
}
}
return proposals.toArray(new IContentProposal[0]);
}
use of org.jkiss.dbeaver.model.runtime.SystemJob in project dbeaver by serge-rider.
the class SQLContextInformer method makeObjectDescription.
public static String makeObjectDescription(@Nullable DBRProgressMonitor monitor, DBPNamedObject object, boolean html) {
final PropertiesReader reader = new PropertiesReader(object, html);
if (monitor == null) {
SystemJob searchJob = new SystemJob("Extract object properties info", reader);
searchJob.schedule();
UIUtils.waitJobCompletion(searchJob);
} else {
reader.run(monitor);
}
return reader.getPropertiesInfo();
}
use of org.jkiss.dbeaver.model.runtime.SystemJob in project dbeaver by dbeaver.
the class SQLContextInformer method makeObjectDescription.
public static String makeObjectDescription(@Nullable DBRProgressMonitor monitor, DBPNamedObject object, boolean html) {
final PropertiesReader reader = new PropertiesReader(object, html);
if (monitor == null) {
SystemJob searchJob = new SystemJob("Extract object properties info", reader);
searchJob.schedule();
UIUtils.waitJobCompletion(searchJob);
} else {
reader.run(monitor);
}
return reader.getPropertiesInfo();
}
use of org.jkiss.dbeaver.model.runtime.SystemJob in project dbeaver by dbeaver.
the class ResultSetFilterPanel method getProposals.
@Override
public IContentProposal[] getProposals(String contents, int position) {
if (!viewer.getPreferenceStore().getBoolean(ResultSetPreferences.RESULT_SET_FILTER_AUTO_COMPLETE_PROPOSIAL)) {
return null;
}
SQLSyntaxManager syntaxManager = new SQLSyntaxManager();
DBPDataSource dataSource = viewer.getDataSource();
if (dataSource != null) {
syntaxManager.init(dataSource);
}
SQLWordPartDetector wordDetector = new SQLWordPartDetector(new Document(contents), syntaxManager, position);
String word = wordDetector.getFullWord();
final List<IContentProposal> proposals = new ArrayList<>();
if (CommonUtils.isEmptyTrimmed(word))
word = contents;
word = word.toLowerCase(Locale.ENGLISH);
String attrName = word;
final DBRRunnableWithProgress reader = monitor -> {
DBDAttributeBinding[] attributes = viewer.getModel().getAttributes();
for (DBDAttributeBinding attribute : attributes) {
if (attribute.isCustom()) {
continue;
}
final String name = DBUtils.getUnQuotedIdentifier(attribute.getDataSource(), attribute.getName());
if (CommonUtils.isEmpty(attrName) || name.toLowerCase(Locale.ENGLISH).startsWith(attrName)) {
final String content = DBUtils.getQuotedIdentifier(attribute) + " ";
proposals.add(new ContentProposalExt(content, attribute.getName(), DBInfoUtils.makeObjectDescription(monitor, attribute.getAttribute(), false), content.length(), DBValueFormatting.getObjectImage(attribute)));
}
}
};
SystemJob searchJob = new SystemJob("Extract attribute proposals", reader);
searchJob.schedule();
UIUtils.waitJobCompletion(searchJob);
String[] filterKeywords = { SQLConstants.KEYWORD_AND, SQLConstants.KEYWORD_OR, SQLConstants.KEYWORD_IS, SQLConstants.KEYWORD_NOT, SQLConstants.KEYWORD_NULL };
for (String kw : filterKeywords) {
if (attrName.isEmpty() || kw.startsWith(attrName.toUpperCase())) {
if (dataSource != null) {
kw = dataSource.getSQLDialect().storesUnquotedCase().transform(kw);
}
proposals.add(new ContentProposal(kw + " ", kw + ": SQL expression keyword"));
}
}
return proposals.toArray(new IContentProposal[0]);
}
Aggregations