private SQLCompletionProposal makeProposalsFromObject( DBPNamedObject object, @Nullable DBPImage objectIcon) { String objectName = DBUtils.getObjectFullName(object); StringBuilder info = new StringBuilder(); PropertyCollector collector = new PropertyCollector(object, false); collector.collectProperties(); for (DBPPropertyDescriptor descriptor : collector.getPropertyDescriptors2()) { Object propValue = collector.getPropertyValue(descriptor.getId()); if (propValue == null) { continue; } String propString = propValue.toString(); info.append("<b>").append(descriptor.getDisplayName()).append(": </b>"); info.append(propString); info.append("<br>"); } boolean isSingleObject = true; String replaceString = null; DBPDataSource dataSource = editor.getDataSource(); if (dataSource != null) { // If we replace short name with referenced object // and current active schema (catalog) is not this object's container then // replace with full qualified name if (!getPreferences().getBoolean(SQLPreferenceConstants.PROPOSAL_SHORT_NAME) && object instanceof DBSObjectReference) { if (wordDetector.getFullWord().indexOf(editor.getSyntaxManager().getStructSeparator()) == -1) { DBSObjectReference structObject = (DBSObjectReference) object; if (structObject.getContainer() != null) { DBSObject selectedObject = getSelectedObject(dataSource); if (selectedObject != structObject.getContainer()) { replaceString = DBUtils.getFullQualifiedName(dataSource, structObject.getContainer(), object); isSingleObject = false; } } } } if (replaceString == null) { replaceString = DBUtils.getQuotedIdentifier(dataSource, object.getName()); } } else { replaceString = DBUtils.getObjectShortName(object); } return createCompletionProposal( replaceString, objectName, info.toString(), objectIcon, isSingleObject, object); }
private void makeProposalsFromAssistant( DBRProgressMonitor monitor, DBSStructureAssistant assistant, @Nullable DBSObjectContainer rootSC, String objectName, List<SQLCompletionProposal> proposals) { try { Collection<DBSObjectReference> references = assistant.findObjectsByMask( monitor, rootSC, assistant.getAutoCompleteObjectTypes(), wordDetector.removeQuotes(objectName) + "%", wordDetector.isQuoted(objectName), 100); for (DBSObjectReference reference : references) { proposals.add(makeProposalsFromObject(reference, reference.getObjectType().getImage())); } } catch (DBException e) { log.error(e); } }