アプリケーションの起動時にロードされるテーブルがあります。このテーブルはコンポジットで作成されます。これで、検索入力に基づいて同じテーブルにデータを入力する別の関数検索ボタンができました。検索結果をテーブルに入力できません。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"}));
テーブルが1つしかないことに注意してください。