Bug 488985

Summary: Bundle common methods of MenuItem and ToolItem in an interface
Product: [Eclipse Project] Platform Reporter: Kay Schröer <Dsn1>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Kay Schröer CLA 2016-03-03 16:14:08 EST
It would be nice if the MenuItem and the ToolItem classes can implement a common interface with some methods like getEnabled/setEnabled, getSelection/setSelection and/or getText/setText so I will be able to f.e. acitivate or deactivate such controls without making any difference:

interface IExample {
  public boolean getEnabled();
  public void setEnabled(boolean value);
  ...
}

class MenuItem implements IExample {
}

class ToolItem implements IExample {
}

IExample item = (IExample) new MenuItem(menuBar, SWT.PUSH);
item.setEnabled(false);

IExample item = (IExample) new ToolItem(toolBar, SWT.PUSH);
item.setEnabled(false);

Another solution would be to refactor these methods to the Item class so I can cast MenuItem and ToolItem to the superclass and then call setEnabled or setSelection etc. on that superclass.