2017-03-28 8 views
0

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

+0

미안하지만 당신이 묻는 것을 이해하지 못합니다. 이 코드는'EditingSupport' 클래스의 일부입니까? –

+0

예 편집 지원의 일부입니다. 내가 원하는 것은 자동 완성 드롭 다운입니다 .http : //stackoverflow.com/users/2670892/greg-449 – Biswabir

+0

또한 첨부 된 이미지를 참조하십시오 – Biswabir

답변

1

서브 클래스 TextCellEditor을. 콘텐츠 제안의 경우 JFace (org.eclipse.jface.fieldassist)의 필드 지원 API를 사용하십시오. 셀 에디터가 처음 작동 될 때 컨텐츠 지원은 을 사용할 수 있습니다 :

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를 재정의해야합니다() 항상 false를 반환합니다. 그렇지 않으면 초점과 관련하여 심각한 문제가 발생할 수 있습니다.