Bug 488985 - Bundle common methods of MenuItem and ToolItem in an interface
Summary: Bundle common methods of MenuItem and ToolItem in an interface
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: PC All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-03 16:14 EST by Kay Schröer CLA
Modified: 2016-03-03 16:27 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.