use of org.apache.felix.upnp.tester.discovery.DriverProxy in project felix by apache.
the class ControlPoint method doMenuBar.
public void doMenuBar(JFrame frame) {
JMenuBar menuBar = new JMenuBar();
// ////////////// FILE
JMenu file_menu = new JMenu("File");
file_menu.setMnemonic(KeyEvent.VK_F);
searchMenu = new JMenu("Search");
final String ALL_DEVICE = "ssdp:all";
final String ROOT_DEVICE = "upnp:rootdevice";
searchMenu.setMnemonic(KeyEvent.VK_L);
searchMenu.setEnabled(false);
AbstractAction searchAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(ALL_DEVICE))
controller.doSearch(ALL_DEVICE);
else if (e.getActionCommand().equals(ROOT_DEVICE))
controller.doSearch(ROOT_DEVICE);
}
};
JMenuItem rootDeviceItem = new JMenuItem("Root Devices");
rootDeviceItem.setMnemonic(KeyEvent.VK_R);
rootDeviceItem.addActionListener(searchAction);
rootDeviceItem.setActionCommand(ROOT_DEVICE);
searchMenu.add(rootDeviceItem);
JMenuItem allDeviceItem = new JMenuItem("All Devices");
allDeviceItem.setMnemonic(KeyEvent.VK_A);
allDeviceItem.addActionListener(searchAction);
allDeviceItem.setActionCommand(ALL_DEVICE);
searchMenu.add(allDeviceItem);
JMenuItem checkIncompleteItem = new JMenuItem("Print Pending Devices");
checkIncompleteItem.setMnemonic(KeyEvent.VK_I);
checkIncompleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mediator.getRootDeviceListener().checkIncompleteDevice();
}
});
JMenuItem checkErrataItem = new JMenuItem("Check Errata UPnPDevices");
checkErrataItem.setMnemonic(KeyEvent.VK_E);
checkErrataItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
RootDeviceListener.checkErrataDevice();
}
});
loggerMenu = new JMenu("Felix Logger");
final String NO_LOGGING = "No Logging";
final String ERROR = "Error";
final String WARNING = "Warning";
final String INFO = "Info";
final String DEBUG = "Debug";
loggerMenu.getPopupMenu().addPopupMenuListener(this);
loggerMenu.setMnemonic(KeyEvent.VK_L);
loggerMenu.setEnabled(false);
AbstractAction loggerAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(NO_LOGGING))
controller.setLogLevel(0);
else if (e.getActionCommand().equals(ERROR))
controller.setLogLevel(1);
else if (e.getActionCommand().equals(WARNING))
controller.setLogLevel(2);
else if (e.getActionCommand().equals(INFO))
controller.setLogLevel(3);
else if (e.getActionCommand().equals(DEBUG))
controller.setLogLevel(4);
}
};
ButtonGroup group = new ButtonGroup();
JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem(NO_LOGGING);
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_N);
rbMenuItem.setActionCommand(NO_LOGGING);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
loggerMenu.addSeparator();
rbMenuItem = new JRadioButtonMenuItem(ERROR);
rbMenuItem.setMnemonic(KeyEvent.VK_E);
rbMenuItem.setActionCommand(ERROR);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(WARNING);
rbMenuItem.setMnemonic(KeyEvent.VK_W);
rbMenuItem.setActionCommand(WARNING);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(INFO);
rbMenuItem.setMnemonic(KeyEvent.VK_I);
rbMenuItem.setActionCommand(INFO);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(DEBUG);
rbMenuItem.setMnemonic(KeyEvent.VK_D);
rbMenuItem.setActionCommand(DEBUG);
rbMenuItem.addActionListener(loggerAction);
group.add(rbMenuItem);
loggerMenu.add(rbMenuItem);
final String ON = "On";
final String OFF = "Off";
cyberMenu = new JMenu("Cyber Debugger");
cyberMenu.getPopupMenu().addPopupMenuListener(this);
cyberMenu.setMnemonic(KeyEvent.VK_C);
cyberMenu.setEnabled(false);
AbstractAction cyberAction = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
DriverProxy controller = Mediator.getDriverProxy();
if (e.getActionCommand().equals(ON))
controller.setCyberDebug(true);
else if (e.getActionCommand().equals(OFF))
controller.setCyberDebug(false);
}
};
ButtonGroup cyberGroup = new ButtonGroup();
rbMenuItem = new JRadioButtonMenuItem(ON);
rbMenuItem.setSelected(true);
rbMenuItem.setMnemonic(KeyEvent.VK_O);
rbMenuItem.setActionCommand(ON);
rbMenuItem.addActionListener(cyberAction);
cyberGroup.add(rbMenuItem);
cyberMenu.add(rbMenuItem);
rbMenuItem = new JRadioButtonMenuItem(OFF);
rbMenuItem.setMnemonic(KeyEvent.VK_F);
rbMenuItem.setActionCommand(OFF);
rbMenuItem.addActionListener(cyberAction);
cyberGroup.add(rbMenuItem);
cyberMenu.add(rbMenuItem);
/*
JMenuItem clearSubscriptionItem = new JMenuItem("Clear Subscriptions");
clearSubscriptionItem.setMnemonic(KeyEvent.VK_S);
clearSubscriptionItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// to do
}
});
*/
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic(KeyEvent.VK_X);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
Activator.context.getBundle().stop();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
file_menu.add(searchMenu);
file_menu.addSeparator();
file_menu.add(loggerMenu);
file_menu.add(cyberMenu);
file_menu.addSeparator();
file_menu.add(checkIncompleteItem);
file_menu.add(checkErrataItem);
// file_menu.addSeparator();
// file_menu.add(clearSubscriptionItem);
file_menu.addSeparator();
file_menu.add(exitItem);
menuBar.add(file_menu);
frame.setJMenuBar(menuBar);
}
Aggregations