2013-02-05 2 views
0

안녕하세요 SWT 테이블새로 고침 테이블 편집기

private Table folderAssociationTable; 
private TableItem   item; 
private TableEditor   editor; 

folderAssociationTable = componentsRenderer.createTableWidget(container, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION, 2, true); 

     folderAssociationTable.addListener(SWT.MeasureItem, new Listener() { 
      public void handleEvent(Event event) { 
       event.height = 20; 
      } 
     }); 

     componentsRenderer.createTableColumWidget(folderAssociationTable, SWT.CHECK, "Item", 80); 
     // add a column to display source folders 
     componentsRenderer.createTableColumWidget(folderAssociationTable, 
       SWT.LEFT, PropertyClass.getPropertyLabel(QTLConstants.SOURCE_FOLDER_COLUMN_LABEL), 200); 
     // add a column to display target folders 
     componentsRenderer.createTableColumWidget(folderAssociationTable, 
       SWT.LEFT, PropertyClass.getPropertyLabel(QTLConstants.TARGET_FOLDER_COLUMN_LABEL), 200); 

을위한 다음과 같은 코드를 가지고 있고 나는 밖에이 페이지에서 버튼을 제거해야

item = new TableItem(folderAssociationTable, SWT.NONE); 
          editor = new TableEditor (folderAssociationTable); 

          Button button = new Button(folderAssociationTable, SWT.CHECK); 
          button.setText("item "+ (i+1)); 
          button.pack(); 
          editor.minimumWidth = button.getSize().x; 
          editor.setEditor(button, item, 0); 

          item.setText(1, folderlist[i]); // add source folder to the first column of the table 
          item.setText(2, targetFolderPath); // add target folder to the second column of the table 
          sourceTargetFolderMap.put(folderlist[i], targetFolderPath); 

이런 식으로 테이블 데이터를 추가 테이블 구성 요소, 해당 동작 수신기에서 테이블에서 선택한 행을 제거 할 때하지만이 경우 테이블 업데이트되는 경우에만 테이블 항목이 업데이트됩니다 있지만 테이블 편집기를 동일한 위치에 남아 어떻게 테이블 편집기 및 테이블 항목을 새로 고칠 수 있습니다. 버튼을 제거하십시오.

답변

1

documentation에 주어진 예를 보았습니까? 이 항목을 ActionListener에 추가 :

// to close the old editor 
Control oldEditor = editor.getEditor(); 
if (oldEditor != null) oldEditor.dispose(); 

// add some logic if you want to open the editor again on a different row