Search in sources :

Example 1 with CompletionProposal

use of com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal in project cubrid-manager by CUBRID.

the class SQLContentAssistProcessor method buildProposals.

/**
	 * Build the proposals with image
	 *
	 * @param names List
	 * @param replacedWord String
	 * @param offset int
	 * @param Image image
	 * @return proposals
	 */
private List<ICompletionProposal> buildProposals(List<String> names, String replacedWord, int offset, Image image, boolean showSecondProposals) {
    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
    for (String name : names) {
        String currSuggestion = name;
        String displayString = name;
        if (checkShowSecondProposals(showSecondProposals, name)) {
            // content += SECONDPROPOSALSUFFIX;
            proposals.add(new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), CommonUIPlugin.getImage("icons/queryeditor/arrow_right.png"), displayString, null, null));
        } else {
            if (QuerySyntax.getKeywordContent(name) == null) {
                proposals.add(new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), image, displayString, null, null));
            } else {
                // show help
                proposals.add(new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), image, null, null, "<pre>" + QuerySyntax.getKeywordContent(name) + "</pre>"));
            }
        }
    }
    return proposals;
}
Also used : CompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal) ICompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal) ICompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList)

Example 2 with CompletionProposal

use of com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal in project cubrid-manager by CUBRID.

the class SQLContentAssistProcessor method buildColumnProposals.

/**
	 * build the column proposals with image
	 *
	 * @param tableColumns List<TableColumn>
	 * @param replacedWord String
	 * @param offset int
	 * @param Image image
	 * @return proposals
	 */
private List<ICompletionProposal> buildColumnProposals(List<ColumnProposalDetailInfo> tableColumns, String replacedWord, int offset, Image image, boolean showSecondProposals) {
    List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
    for (ColumnProposalDetailInfo column : tableColumns) {
        String columnName = column.getColumnName();
        String currSuggestion = columnName;
        String displayString = columnName;
        if (replacedWord.indexOf(".") > 0) {
            String[] words = replacedWord.split("\\.");
            currSuggestion = words[0] + "." + column.getColumnName();
        }
        if (checkShowSecondProposals(showSecondProposals, column.getColumnName())) {
            proposals.add(new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), CommonUIPlugin.getImage("icons/queryeditor/arrow_right.png"), displayString, null, column.getColumnAdditionalInfo()));
        } else {
            proposals.add(new CompletionProposal(currSuggestion, offset, replacedWord.length(), currSuggestion.length(), image, displayString, null, "<pre>" + column.getColumnAdditionalInfo() + "</pre>"));
        }
    }
    return proposals;
}
Also used : CompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal) ICompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal) ICompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList)

Example 3 with CompletionProposal

use of com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal in project cubrid-manager by CUBRID.

the class SQLContentAssistProcessor method computeSecondProposals.

/**
	 * compute Second Proposals
	 *
	 * @param viewer
	 * @param offset
	 * @param firstProposalsSelectedProposal
	 * @return ICompletionProposal[]
	 */
public ICompletionProposal[] computeSecondProposals(ITextViewer viewer, int offset, ICompletionProposal firstProposalsSelectedProposal) {
    IDocument document = viewer.getDocument();
    int currOffset = offset - 1;
    try {
        String currWord = "";
        char currChar;
        while (currOffset >= 0 && !isKeywordSeparator(currChar = document.getChar(currOffset))) {
            currWord = Character.toUpperCase(currChar) + currWord;
            currOffset--;
        }
        List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
        String firstProposalsDisplayString = firstProposalsSelectedProposal.getDisplayString();
        for (String sql : RecentlyUsedSQLContentPersistUtils.getRecentlyUsedSQLContentsById(databaseProvider.getDatabase())) {
            if (StringUtil.startsWithIgnoreCase(firstProposalsDisplayString, sql)) {
                String content = "";
                if (sql.length() > 60) {
                    content = sql.substring(0, 57);
                    content += "...";
                } else {
                    content = sql;
                }
                proposals.add(new CompletionProposal(sql, offset - currWord.length(), currWord.length(), sql.length(), CommonUIPlugin.getImage("icons/queryeditor/arrow_left.png"), content, null, sql));
            }
        }
        return proposals.toArray(new ICompletionProposal[proposals.size()]);
    } catch (Exception e) {
        LOGGER.error("", e);
        return null;
    }
}
Also used : CompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal) ICompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal) ICompletionProposal(com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal) ArrayList(java.util.ArrayList) IDocument(org.eclipse.jface.text.IDocument) SQLException(java.sql.SQLException) BadLocationException(org.eclipse.jface.text.BadLocationException)

Aggregations

CompletionProposal (com.cubrid.common.ui.query.control.jface.text.contentassist.CompletionProposal)3 ICompletionProposal (com.cubrid.common.ui.query.control.jface.text.contentassist.ICompletionProposal)3 ArrayList (java.util.ArrayList)3 SQLException (java.sql.SQLException)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IDocument (org.eclipse.jface.text.IDocument)1