Guest User

Untitled

a guest
Aug 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Eclipse Table widget with SWT.CHECK is fireing two events when a TableItem is selected
  2. final Table table = new Table( composite, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION | SWT.CHECK );
  3. table.setHeaderVisible(true);
  4. table.setLinesVisible(false);
  5.  
  6. (...)
  7.  
  8. table.addSelectionListener(new SelectionAdapter() {
  9. public void widgetSelected(SelectionEvent e) {
  10. CheckThatOnlyOneItemCanBeCheckedAtTime(e.item);
  11. //If someone check on me, save the item data value in a "container"
  12. if( e.detail == SWT.CHECK ) {
  13. MBSCustomPageManager.addPageProperty(PAGE_ID, "SDK_Path", ((ISdk)((TableItem)e.item).getData()).getPath() );
  14. } else { //Otherwise, unset the saved value
  15. MBSCustomPageManager.addPageProperty(PAGE_ID, "SDK_Path", "" );
  16. }
  17. }
  18. });
  19.  
  20. table.addListener(SWT.Selection, new Listener() {
  21. public void handleEvent(Event arg0) {
  22. String string = arg0.detail == SWT.CHECK ? "Checked"
  23. : "Selected";
  24. if (arg0.detail == SWT.CHECK)
  25. System.out.println(arg0.item + " " + string+":"+((Table)arg0.widget).getSelection()[0].getChecked());
  26. else
  27. System.out.println(arg0.item + " " + string);
  28. }
  29. });
Add Comment
Please, Sign In to add comment