我有在应用程序启动时加载的表。此表是在复合中创建的。现在我有另一个功能搜索按钮,它将根据搜索输入填充同一个表。我无法用搜索结果填充表格。是否可以根据使用 SWT/Jface 的功能(在应用程序启动/搜索结果时加载)在同一个表中进行切换。例如应用程序启动时的表值显示
m_workplaceViewer = new TableViewer(table);
String[] workplace_titles= new String[]{"Code","Plant","Compy Reg Num","Num Of Employees","Type of industry","Type of products/service", "Representative","Main Phone","Phone 1","Phone 2","Fax", "Zip Code",
"Address 1","Address 2","Email","HomePage","Note 1","Note 2","Note 3","Note 4","Note 5"};
for (int i = 0; i < 21; i++){
TableViewerColumn column_workplace = new TableViewerColumn(m_workplaceViewer,
SWT.NONE);
column_workplace.getColumn().setWidth(75);
column_workplace.getColumn().setText(workplace_titles[i]);
}
try {
workplaceDetailList= workplaceDaoImpl.getWorkplaceDetails();
} catch (SQLException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
}
对于搜索按钮
btnSearch.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
String plant=text_workplace.getText();
System.out.println("Select Me : " + plant);
IStructuredSelection selection = (IStructuredSelection) m_workplaceViewer
.getSelection();
if (selection.getFirstElement() instanceof WorkplaceDetail) {
workplaceDetail = (WorkplaceDetail) selection.getFirstElement();
}
System.out.println("Start Search--2");
if (plant!=""){
table.removeAll();
workplaceDetailList=workplaceDaoImpl.getWorkplaceDetailsSearchByPlant(plant);
m_workplaceViewer.setInput(workplaceDetailList)
}
数据绑定:
ObservableListContentProvider m_personViewerContentProviderList1 = new ObservableListContentProvider();
m_workplaceViewer.setContentProvider(m_personViewerContentProviderList1);
IObservableList input =
Properties.selfList(WorkplaceDetail.class).observe(workplaceDetailList);
m_workplaceViewer.setInput(input);
ViewerSupport.bind(m_workplaceViewer,
input,
BeanProperties.values(new String[] {"code","plant","compRegNum","numOfEmps","typeIndst",
"typeProd","employee.empName","address.mainPhone","address.phone1","address.phone2",
"address.fax", "address.zip", "address.add1", "address.add2","address.empEmail",
"address.homepage","note1", "note2", "note3", "note4", "note5"}));
请不要说我只有一张桌子。