양식 섹션 내에 SWT 테이블을 표시하려고하지만 열 크기 조정 및 스크롤에 문제가 있습니다.SWT 섹션 테이블 및 스크롤
이클립스 plugin의 ViewPart에 배치 할 수있는 몇 가지 샘플 코드를 첨부했습니다 (3.7은 내가 사용하고있는 버전 임). 코드를 실행하고 오른쪽의 열의 크기를 조정하면 테이블에 가로 스크롤 막대가 생깁니다.
이제 섹션을 축소하면 ("섹션 제목"의 왼쪽에있는 화살표를 클릭하십시오),보기에는 가로 스크롤 막대가 생깁니다 (원하지 않습니다). 섹션을 다시 확장하면 뷰 스크롤이 남아 있고 테이블에 더 이상 테이블이 없습니다.
보기보다 넓은 테이블을 막을 수있는 방법 (아마도 중첩 된 합성물의 약간의 끔찍한 조합)을 찾고있어 어떤 제안이라도 고맙게 생각합니다.
public class ExampleView extends ViewPart {
/** Note: other fields/methods removed to condense snippet */
private FormToolkit toolkit;
private ScrolledForm scrolledForm;
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
toolkit = new FormToolkit(parent.getDisplay());
scrolledForm = toolkit.createScrolledForm(parent);
scrolledForm.setExpandHorizontal(true);
scrolledForm.setText("Form Title");
scrolledForm.getBody().setLayout(new FillLayout());
// here's the modification for the solution
scrolledForm.getBody().setLayout(
new BoundedLayout(new FillLayout(), true));
final Section section = toolkit.createSection(scrolledForm.getBody(),
Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE
| Section.EXPANDED);
section.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
scrolledForm.reflow(true);
}
});
section.setText("Section Title");
final Table table = toolkit.createTable(section, SWT.FULL_SELECTION);
TableViewer viewer = new TableViewer(table);
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setItemCount(10);
TableColumn col = new TableColumn(table, SWT.NONE);
col.setText("Column A");
col.setWidth(150);
col.setResizable(true);
col.setMoveable(true);
TableColumn col2 = new TableColumn(table, SWT.NONE);
col2.setText("Column B");
col2.setWidth(150);
col2.setResizable(true);
col2.setMoveable(true);
section.setClient(table);
}
}
마이너 업데이트를 그대로 적용해야 성가신 틱 반사 해킹 있습니다
- 나는 소스에서 참조가 section.setLayout'호출 (새 FillLayout());'는 섹션 –