use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand in project ovirt-engine by oVirt.
the class NetworkPanel method onAction.
@Override
protected void onAction() {
if (item.isManaged()) {
item.edit();
} else {
Map<NetworkOperation, List<NetworkCommand>> operationMap = item.getSetupModel().commandsFor(item);
final NetworkCommand detach = operationMap.get(NetworkOperation.REMOVE_UNMANAGED_NETWORK).get(0);
item.getSetupModel().onOperation(NetworkOperation.REMOVE_UNMANAGED_NETWORK, detach);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkCommand in project ovirt-engine by oVirt.
the class NetworkItemPanel method menuFor.
/**
* Generate a Menu for the provided Network Item.
*/
private MenuBar menuFor(NetworkItemModel<?> item) {
MenuBar menu = rootMenu(item);
Map<NetworkOperation, List<NetworkCommand>> operationMap = item.getSetupModel().commandsFor(item);
for (final Entry<NetworkOperation, List<NetworkCommand>> entry : operationMap.entrySet()) {
final List<NetworkCommand> commands = entry.getValue();
if (entry.getKey().isUnary()) {
// $NON-NLS-1$
assert commands.size() == 1 : "Got a NetworkCommand List with more than one Unary Operation";
menu.addItem(entry.getKey().getVerb(item), () -> executeCommand(entry.getKey(), commands.get(0)));
} else {
Collections.sort(commands, Comparator.comparing(NetworkCommand::getName, new LexoNumericComparator()));
MenuBar subMenu = subMenu();
for (final NetworkCommand command : commands) {
subMenu.addItem(new MenuItem(command.getName(), () -> executeCommand(entry.getKey(), command)));
}
menu.addItem(entry.getKey().getVerb(item), subMenu);
}
}
return menu;
}
Aggregations