use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method onOperation.
public void onOperation(NetworkOperation operation, final NetworkCommand networkCommand) {
Model popupWindow;
UICommand cancelCommand = new UICommand("Cancel", new // $NON-NLS-1$
BaseCommandTarget() {
@Override
public void executeCommand(UICommand command) {
sourceListModel.setConfirmWindow(null);
}
});
cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
cancelCommand.setIsCancel(true);
if (operation.isNullOperation()) {
return;
} else if (operation == NetworkOperation.BOND_WITH || operation == NetworkOperation.JOIN_BONDS) {
final SetupNetworksBondModel bondPopup;
boolean doesBondHaveVmNetworkAttached = doesBondHaveVmNetworkAttached((NetworkInterfaceModel) networkCommand.getOp1(), (NetworkInterfaceModel) networkCommand.getOp2());
if (operation == NetworkOperation.BOND_WITH) {
bondPopup = new SetupNetworksAddBondModel(getFreeBonds(), nextBondName, doesBondHaveVmNetworkAttached);
} else {
bondPopup = new SetupNetworksJoinBondsModel(getFreeBonds(), (BondNetworkInterfaceModel) networkCommand.getOp1(), (BondNetworkInterfaceModel) networkCommand.getOp2(), doesBondHaveVmNetworkAttached);
}
bondPopup.getCommands().add(new UICommand("OK", new // $NON-NLS-1$
BaseCommandTarget() {
@Override
public void executeCommand(UICommand command) {
if (!bondPopup.validate()) {
return;
}
sourceListModel.setConfirmWindow(null);
CreateOrUpdateBond bond = new CreateOrUpdateBond();
bond.setName(bondPopup.getBond().getSelectedItem());
setBondOptions(bond, bondPopup);
NetworkInterfaceModel nic1 = (NetworkInterfaceModel) networkCommand.getOp1();
NetworkInterfaceModel nic2 = (NetworkInterfaceModel) networkCommand.getOp2();
// Store networks
List<LogicalNetworkModel> networks = new ArrayList<>();
networks.addAll(nic1.getItems());
networks.addAll(nic2.getItems());
// Store labels
List<NetworkLabelModel> labels = new ArrayList<>();
labels.addAll(nic1.getLabels());
labels.addAll(nic2.getLabels());
networkCommand.execute(bond);
/*
* We are calling the <code>redraw()</code> to create the BondModel which is needed by the following
* operations (attaching the networks and the labels to the bond).
*
* For more details @see #redraw. After executing the <code>networkCommand</code> which creates the
* bond, the bondModel still not exist (only the <code>hostSetupNetworksParametersData.bonds</code>
* are updated). <code>redraw()</code> has to be called to create it.
*/
redraw();
// Attach the previous networks
attachNetworks(bond.getName(), networks);
// Attach previous labels
attachLabels(bond.getName(), labels);
redraw();
}
}));
popupWindow = bondPopup;
} else if (networkCommand.getOp1() == getNewNetworkLabelModel()) {
final SetupNetworksLabelModel labelPopup = new SetupNetworksLabelModel(dcLabels);
labelPopup.getCommands().add(new UICommand("OK", new // $NON-NLS-1$
BaseCommandTarget() {
@Override
public void executeCommand(UICommand uiCommand) {
if (!labelPopup.validate()) {
return;
}
sourceListModel.setConfirmWindow(null);
String label = labelPopup.getLabel().getEntity();
dcLabels.add(label);
NetworkOperation.LABEL.getCommand(new NetworkLabelModel(label, HostSetupNetworksModel.this), networkCommand.getOp2(), hostSetupNetworksParametersData).execute();
redraw();
}
}));
popupWindow = labelPopup;
} else {
// just execute the command
networkCommand.execute();
redraw();
return;
}
// add cancel
popupWindow.getCommands().add(cancelCommand);
// set window
sourceListModel.setConfirmWindow(popupWindow);
}
use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class HostListModel method assignTags.
public void assignTags() {
if (getWindow() != null) {
return;
}
TagListModel model = new TagListModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().assignTagsTitle());
model.setHelpTag(HelpTag.assign_tags_hosts);
// $NON-NLS-1$
model.setHashName("assign_tags_hosts");
getAttachedTagsToSelectedHosts(model);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAssignTags", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class HostListModel method stop.
public void stop(String uiCommand) {
ConfirmationModel model = new ConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().stopHostsTitle());
model.setHelpTag(HelpTag.stop_host);
// $NON-NLS-1$
model.setHashName("stop_host");
model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantToStopTheFollowingHostsMsg());
// model.Items = SelectedItems.Cast<VDS>().Select(a => a.vds_name);
ArrayList<String> items = new ArrayList<>();
for (Object item : getSelectedItems()) {
VDS vds = (VDS) item;
items.add(vds.getName());
}
model.setItems(items);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand(uiCommand, this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class HostListModel method maintenance.
private void maintenance(boolean isMaintenanceReasonVisible, boolean supportsGlusterService) {
if (getConfirmWindow() != null) {
return;
}
HostMaintenanceConfirmationModel model = new HostMaintenanceConfirmationModel();
setConfirmWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().maintenanceHostsTitle());
model.setHelpTag(HelpTag.maintenance_host);
// $NON-NLS-1$
model.setHashName("maintenance_host");
model.setMessage(ConstantsManager.getInstance().getConstants().areYouSureYouWantToPlaceFollowingHostsIntoMaintenanceModeMsg());
model.setReasonVisible(isMaintenanceReasonVisible);
if (supportsGlusterService) {
model.getStopGlusterServices().setIsAvailable(true);
model.getStopGlusterServices().setEntity(false);
model.getForce().setIsAvailable(true);
model.getForce().setEntity(false);
model.setForceLabel(ConstantsManager.getInstance().getConstants().ignoreGlusterQuorumChecks());
}
// model.Items = SelectedItems.Cast<VDS>().Select(a => a.vds_name);
ArrayList<String> vdss = new ArrayList<>();
for (Object item : getSelectedItems()) {
VDS vds = (VDS) item;
vdss.add(vds.getName());
}
model.setItems(vdss);
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnMaintenance", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("CancelConfirm", this);
model.getCommands().add(tempVar2);
}
use of org.ovirt.engine.ui.uicommonweb.UICommand in project ovirt-engine by oVirt.
the class HostListModel method remove.
public void remove() {
if (getWindow() != null) {
return;
}
final ConfirmationModel model = new ConfirmationModel();
setWindow(model);
model.setTitle(ConstantsManager.getInstance().getConstants().removeHostsTitle());
model.setHelpTag(HelpTag.remove_host);
// $NON-NLS-1$
model.setHashName("remove_host");
Set<Guid> clusters = new HashSet<>();
ArrayList<String> list = new ArrayList<>();
boolean heOnHosts = false;
for (VDS item : getSelectedItems()) {
clusters.add(item.getClusterId());
String name = item.getName();
if (item.isHostedEngineDeployed()) {
// $NON-NLS-1$
name = name + " *";
heOnHosts = true;
}
list.add(name);
}
model.setItems(list);
if (heOnHosts) {
model.setNote(ConstantsManager.getInstance().getConstants().heHostRemovalWarning());
}
// - the cluster should have gluster service enabled
if (clusters.size() == 1) {
model.startProgress();
AsyncDataProvider.getInstance().getClusterById(new AsyncQuery<>(cluster -> {
if (cluster != null && cluster.supportsGlusterService()) {
model.getForce().setIsAvailable(true);
}
model.stopProgress();
}), clusters.iterator().next());
}
// $NON-NLS-1$
UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
model.getCommands().add(tempVar);
// $NON-NLS-1$
UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
model.getCommands().add(tempVar2);
}
Aggregations