2014-03-04 2 views
0

는 이클립스 마법사에 대해 다음 Java 코드를 관련하여 모든 항목을 제거한 후 남아 : 내가 한 번만이 페이지를 호출 할 때는 - 사용자 정의 위젯은

public class PageTypes extends WizardPage 
{ 

    private Table types; 

    @Override 
    public void setVisible(boolean visible) 
    { 
     // if we get visible, we want to update the tables! 
     if(visible) 
      initialize(); 
     super.setVisible(visible); 
    } 

    private void initialize() 
    { 
     types.setRedraw(false); 
     types.removeAll(); 
     types.setRedraw(true); 
     ... 
     //getting data from database and start a cycle for adding rows 
     ... 
     //adding data for cells in first two columns: plain text - no problems here 
     ... 
     TableEditor editor = new TableEditor (types); 
     Button checkButton = new Button(types, SWT.CHECK); 
     checkButton.setSelection(true); 
     checkButton.pack(); 
     editor.minimumWidth = checkButton.getSize().x; 
     editor.horizontalAlignment = SWT.CENTER; 
     editor.setEditor(checkButton, item, 2); 
     ... 
     //here comes another widget (comboBox) for the fourth column 
     ... 
    } 
} 

이 지금까지 작동합니다. 다시 돌아가서 다시 전달하면 removeAll()은 모든 일반 텍스트 항목을 제거하지만 checkButtons 및 comboBoxes로는 아무 것도 수행하지 않습니다. 그래서 테이블을 다시 그리면 요소가 두 번 나타납니다. 페이지간에 전환하는 동안 다른 데이터 소스를 선택하면 더 이상해 보입니다.

screenshot

어떤 제안 : 여기 내 문제가 더 명확하게 할 수있는 스크린 샷은입니까?

+0

에서 캐롤린 ​​MacLeod에에

//this goes in the cycle where widgets are created item.setData("checkButtonEditor", editor); //here comes another widget (comboBox) for the fourth column item.setData("checkBoxEditor", editor); //this goes into the beggining of initialze-method types.setRedraw(false); TableItem[] items = types.getItems(); for (TableItem item : items) { TableEditor editor = (TableEditor)item.getData("checkButtonEditor"); editor.getEditor().dispose(); editor.dispose(); editor = (TableEditor)item.getData("checkBoxEditor"); editor.getEditor().dispose(); editor.dispose(); } types.removeAll(); types.setRedraw(true); 

감사합니다. –

+0

감사합니다.이 솔루션도 고려할 것입니다. –

답변

0

내 문제를 해결하는 방법을 알아 냈습니다. 위젯 용 모든 단일 편집기에 대한 참조를 저장 한 다음 항목을 제거하기 전에 폐기해야했습니다. 여기 단편이다 : 당신은`TableViewer`와`CellEditor`을 사용할 수 있습니다 dev.eclipse.org