简体   繁体   中英

JFace : Clear contents of a ListViewer prior to setting input.(Clear all the contents without using Selection listener)

I have 2 Wizard pages and a ListViewer in both the pages.

In the first Wizard Page I have a ListViewer wherein If I select the items from the ListViewer of the 1st Wizard page and Click "Next" button then these selected items are brought to the second Wizard page and displayed in the ListViewer of the Second Wizard page. Everything is fine until now, my problem is :

If I click "Back" button from the 2nd Wizard page and once again make selections of same items that I had selected for the first time and then click "Next" button then in the 2nd page's list viewer duplicate items are being displayed, each item of the 1st Wizard page is being displayed twice. Once again If I go back to previous wizard page and select the same items and again click "Next" then each item displays thrice in the list viewer of Second wizard page.

Is there a way to clear the contents of a list viewer prior to setting input? If I could clear all the contents of the List viewer prior to setting input then I could avoid duplicate items being displayed in the 2nd Wizard page. I know to clear contents through selecting items in the viewer but how do I clear all the contents of a viewer without making selections or without using a selection listener?

Someone Please help me here,Any suggestions would be appreciated.

Thanks.

Just call the ListViewer.setInput method to replace the old input with new input.

Using setInput(null) will clear the input.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM