I have table which get's loaded when application starts. This table is created in composite. Now i have another function search button which will populate the same table based on search input. I am not able to populate table with search result. Is it possible to switch within same table depending on functionality (load on application start /search result) using SWT/Jface. For example Table value display on application start up
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();
}
For search button
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)
}
Databinding :
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"}));
Please not that i have only one table.