如何通过在 ComboBoxViewerCellEditor 中键入相应的字母表来获取下拉列表

how to get drop down list by type respective alphabet in ComboBoxViewerCellEditor

ComboBoxViewerCellEditor 我想写点东西,结果我会得到匹配的下拉值。

你能建议如何获得这个吗?请在下面找到代码:

public TCOperationColumnEditable(TableViewer viewer) {
    super(viewer);
    try
    {
        this.viewer = viewer;
        //this.editor = new TextCellEditor(this.viewer.getTable());

        OperationGSON[] allOperations = OperationAPIHandler.getInstance().getAllOperations();

        ArrayList<String> opnName = new ArrayList<String>();

        for(OperationGSON opn : allOperations)
        {
            opnName.add(opn.opnName);
        }
        this.editor = new ComboBoxViewerCellEditor(this.viewer.getTable(), SWT.FULL_SELECTION );

    this.editor.setLabelProvider(new LabelProvider());
    this.editor.setContentProvider(new ArrayContentProvide());
    this.editor.setInput(opnName);
    String[] stockArr = new String[opnName.size()];
    stockArr = opnName.toArray(stockArr);
    new AutoCompleteField(this.viewer.getControl(), new CComboContentAdapter(), stockArr); 
    }
    catch(Exception e)
    {
        System.out.println("[" + getClass().getName() + " : TCOperationColumnEditable()] - Exception : " + e.getMessage());
        e.printStackTrace();
    }
}

enter image description here

子类 TextCellEditor。 对于内容提案,使用 JFace 的字段辅助 API (org.eclipse.jface.fieldassist)。内容辅助已启用 第一次激活单元格编辑器时:

if (contentProposalAdapter == null) {
    .... 
    // enable content assist on the cell editor's text widget 
    contentProposalAdapter = new ContentProposalAdapter(text, new TextContentAdapter(), proposalProvider, activationKeyStroke, null); 
} else { 
    contentProposalAdapter.setEnabled(true); 
}
super.activate(); 
....

确保也重写方法 TextCellEditor#dependsOnExternalFocusListener() 总是 return false。 否则,您将面临一些与焦点有关的严重问题。